📄 m23 - reading free-format data - 38 of 40.mht
字号:
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_13.htm">missing =
values=20
at the end of a record</A>, you can use the INFILE statement =
with the=20
MISSOVER option to prevent SAS from going to the next record to =
find the=20
missing values.=20
<P>If your data contains missing values at the beginning or in the =
middle=20
of a record, you might be able to use the <A=20
onmouseover=3D"window.status=3D'Display details on the limitations =
of list input.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_14.htm">DSD =
option</A>=20
in the INFILE statement to correctly read the raw data. The DSD =
option=20
sets the default delimiter to a comma and treats two consecutive=20
delimiters as a missing value.=20
<P>If the data uses multiple delimiters or a single delimiter =
other than a=20
comma, you can use both the <A=20
onmouseover=3D"window.status=3D'Display details on using the DSD =
option with the DLM=3D option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_14.htm#both">DSD =
option=20
and the DLM=3D option</A> in the INFILE statement.=20
<P>The DSD option can also be used to read raw data when there is =
a=20
missing value at the <A=20
onmouseover=3D"window.status=3D'Display details on using the DSD =
option when there is a missing value at the beginning of a record.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_14.htm#begin">beginni=
ng=20
of a record</A>, as long as a delimiter precedes the first value =
in the=20
record.=20
<P><STRONG>Specifying the Length of Character Values =
</STRONG><BR>You can=20
<A=20
onmouseover=3D"window.status=3D'Display details on changing the =
length of character variables.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_18.htm">specify the=20
length of character variables</A> by using the <A=20
onmouseover=3D"window.status=3D'Display details on the LENGTH =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_19.htm">LENGTH =
statement</A>. The LENGTH statement enables you to use list input =
to read=20
names that are longer than eight characters without truncating =
them.=20
<P>Because variable attributes are defined when the variable is =
first=20
encountered in the DATA step, the LENGTH statement precedes the =
INPUT=20
statement and defines both the length and the type of the =
variable.=20
<P>When you use the LENGTH statement, you do not need to =
specify the=20
variable type again in the INPUT statement.=20
<P><STRONG>Modifying List Input </STRONG><BR><A=20
onmouseover=3D"window.status=3D'Display details on modified list =
input.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_22.htm">Modified =
list=20
input</A> can be used to read values that contain embedded blanks =
and=20
nonstandard values. Modified list input uses two format modifiers: =
<UL>
<LI>the <A=20
onmouseover=3D"window.status=3D'Display details on the & =
modifier.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_23.htm">ampersand=20
(&) modifier</A> enables you to read character values that =
contain=20
single embedded blanks=20
<LI>the <A=20
onmouseover=3D"window.status=3D'Display details on the : =
modifier.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_24.htm">colon (:)=20
modifier</A> enables you to read nonstandard data values and =
character=20
values that are longer than eight characters, but which contain =
no=20
embedded blanks. </LI></UL>
<P>Remember that informats <A=20
onmouseover=3D"window.status=3D'Display details on comparing =
modified list input and formatted input.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_26.htm">work=20
differently</A> in modified list input than they do in formatted =
input.=20
<P><STRONG>Creating Free-Format Data</STRONG><BR>You can create a =
raw data=20
file using <A=20
onmouseover=3D"window.status=3D'Display details on list output.'; =
"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_29.htm">list =
output</A>.=20
With list output, you simply list the names of the variables whose =
values=20
you want to write. The PUT statement writes a variable, leaves a =
blank,=20
then writes the next value.=20
<P>You can use the <A=20
onmouseover=3D"window.status=3D'Display details on the DLM=3D =
option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_29.htm#DLM">DLM=3D=20
option</A> with a FILE statement to create a delimited raw data =
file. You=20
can use the <A=20
onmouseover=3D"window.status=3D'Display details on the DSD =
option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_30.htm">DSD =
option</A>=20
in a FILE statement to specify that data values containing commas =
should=20
be enclosed in quotation marks. You can also use the DSD option to =
<A=20
onmouseover=3D"window.status=3D'Display details on reading values =
that contain delimiters.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_31.htm">read =
values that=20
contain delimiters</A> within a quoted string.=20
<P><STRONG>Mixing Input Styles</STRONG> <BR>With some file =
layouts, you=20
might need to <A=20
onmouseover=3D"window.status=3D'Display details on mixing input =
styles.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_35.htm">mix =
input=20
styles</A> in the same INPUT statement in order to read the data=20
correctly. </P></TD></TR></TBODY></TABLE><!-- InstanceEndEditable =
--><BR>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" align=3Dcenter =
border=3D0>
<TBODY>
<TR>
<TD align=3Dleft>
<HR>
</TD></TR></TBODY></TABLE>
<P><!-- InstanceBeginEditable name=3D"syntax" -->
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD><STRONG><A name=3DSyntax>Syntax</A></STRONG>=20
<P><EM>To go to the page where a statement or option was =
presented, select=20
a link.</EM>=20
<BLOCKQUOTE>
<P align=3Dleft><STRONG>Reading Free-Format Data</STRONG> </P>
<P align=3Dleft><FONT color=3D#003399><STRONG>LIBNAME</STRONG>=20
<EM>libref</EM>=20
=
<STRONG>'</STRONG><EM>SAS-data-library</EM><STRONG>';</STRONG></FON=
T><BR><FONT=20
color=3D#003399><STRONG>FILENAME </STRONG><EM>fileref=20
=
</EM><STRONG>'</STRONG><EM>filename</EM><STRONG>';</STRONG></FONT><BR><FO=
NT=20
color=3D#003399><STRONG>DATA=20
=
</STRONG><EM>SAS-data-set</EM>;<BR> =20
<STRONG>INFILE </STRONG><EM>file-specification </EM><A=20
onmouseover=3D"window.status=3D'Display details on the DLM=3D =
option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_8.htm"><STRONG><DL=
M=3D'</STRONG><EM>delimiter</EM><STRONG>'></STRONG></A></FONT>=20
<FONT color=3D#003399><STRONG><A=20
onmouseover=3D"window.status=3D'Display details on the MISSOVER =
option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_13.htm"><MISSOVER&=
gt;</A>=20
<A onmouseover=3D"window.status=3D'Display details on the DSD =
option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_14.htm"><DSD>;<=
/A></STRONG></FONT><BR><FONT=20
color=3D#003399> <A=20
onmouseover=3D"window.status=3D'Display details on the LENGTH =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_19.htm"><STRONG>LENGT=
H</STRONG>=20
<EM>variable</EM> <STRONG>$</STRONG>=20
<EM>length</EM><STRONG>;</STRONG></A></FONT>=20
<BR> <FONT =
color=3D#003399><A=20
onmouseover=3D"window.status=3D'Display details on list input.'; =
"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_3.htm"><STRONG>INPUT =
</STRONG><EM>variable </EM><STRONG><$></STRONG></A></FONT> =
<FONT color=3D#003399><A=20
onmouseover=3D"window.status=3D'Display details on modified list =
input.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_22.htm"><STRONG>=20
=
<&|:><</STRONG><EM>informat<STRONG>></STRONG></EM><STRONG=
>;</STRONG></A></FONT><BR><FONT=20
color=3D#003399><STRONG>RUN;<BR>PROC PRINT=20
=
DATA=3D</STRONG><EM>SAS-data-set</EM><STRONG>;<BR></STRONG><STRONG>RUN;=20
</STRONG></FONT><BR></P>
<P align=3Dleft><STRONG>Creating Free-Format =
Data</STRONG></P></BLOCKQUOTE>
<BLOCKQUOTE>
<P align=3Dleft><FONT color=3D#003399><STRONG>LIBNAME</STRONG>=20
<EM>libref</EM>=20
=
<STRONG>'</STRONG><EM>SAS-data-library</EM><STRONG>';</STRONG></FON=
T><BR><FONT=20
color=3D#003399><STRONG>DATA=20
=
_NULL_</STRONG>;</FONT><BR> <FONT=20
color=3D#003399><STRONG>SET=20
</STRONG><EM>SAS-data-set</EM><STRONG>;</STRONG></FONT>=20
<BR> <NOBR><FONT=20
color=3D#003399><STRONG>FILE </STRONG><EM>file-specification =
</EM><A=20
onmouseover=3D"window.status=3D'Display details on the DLM=3D =
option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m23/m23_29.htm#DLM"><STRONG>&=
lt;DLM=3D'</STRONG><EM>delimiter</EM><STRONG>'></STRONG></A>=20
<STRONG><A=20
onmouseover=3D"window.status=3D'Display details on the PUT =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -