📄 m19 - reading raw data in fixed fields - 32 of 34.mht
字号:
<A=20
onmouseover=3D"window.status=3D'Display details on choosing an =
input style.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_7.htm">two =
input=20
styles</A> for reading data in fixed fields, <STRONG>column =
input</STRONG>=20
and <STRONG>formatted input</STRONG>. You can use=20
<UL>
<LI>column input to read standard data only=20
<LI>formatted input to read both standard and nonstandard data.=20
</LI></UL></TD></TR></TBODY></TABLE></CENTER>
<P align=3Dcenter>
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD align=3Dleft><STRONG>Using Formatted Input </STRONG><BR><A=20
onmouseover=3D"window.status=3D'Display details on formatted =
input.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_8.htm">Formatted=20
input</A> uses column pointer controls to position the input =
pointer on a=20
specified column. A column pointer control is optional when the =
first=20
variable is in the first column.=20
<P><A=20
onmouseover=3D"window.status=3D'Display details on the @n pointer =
control.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_9.htm">The=20
@<EM>n</EM></A><EM> </EM>is an absolute pointer control that moves =
the=20
input pointer to a specific column number. You can <A=20
onmouseover=3D"window.status=3D'Display details on reading columns =
in any order.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_11.htm">read =
columns in=20
any order</A> with the @<EM>n </EM>column pointer control.=20
<P><A=20
onmouseover=3D"window.status=3D'Display details on the +n pointer =
control.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_14.htm">The=20
+<EM>n</EM></A><EM> </EM>is a relative pointer control that moves =
the=20
input pointer forward to a column number that is relative to the =
current=20
position. The +<EM>n</EM> pointer control cannot move backwards. =
However,=20
you can use the notation +(-<EM>n</EM>) to move the pointer =
control=20
backwards. </P></TD></TR></TBODY></TABLE></CENTER>
<P align=3Dcenter>
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD align=3Dleft><STRONG>Using Informats</STRONG><BR>An informat =
tells SAS=20
how to read raw data. There are informats for reading <A=20
onmouseover=3D"window.status=3D'Display details on reading =
character values.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_19.htm">standard and =
nonstandard character values</A> and for reading <A=20
onmouseover=3D"window.status=3D'Display details on reading =
standard data values.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_21.htm">standard</A> =
and=20
<A=20
onmouseover=3D"window.status=3D'Display details on reading =
nonstandard data values.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_23.htm">nonstandard=20
numeric data values</A>.=20
<P>Informats always contain a <EM>w </EM>value to indicate the =
width of=20
the raw data field. A period (.) ends the informat or separates =
the=20
<EM>w</EM> value from the optional <EM>d</EM> value, which =
specifies the=20
number of implied decimal places. =
</P></TD></TR></TBODY></TABLE></CENTER>
<P align=3Dcenter>=20
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD align=3Dleft><STRONG>Record Formats </STRONG><BR>A record format =
specifies how records are organized in a file. Some operating =
systems have=20
different types of record formats; the two most common are <A=20
onmouseover=3D"window.status=3D'Display details on fixed-length =
records.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_28.htm#fixed">fixed-l=
ength=20
records</A> and <A=20
onmouseover=3D"window.status=3D'Display details on variable-length =
records.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_28.htm#variable">vari=
able-length=20
records</A>.=20
<P>When you read <A=20
onmouseover=3D"window.status=3D'Display details on reading =
variable-length records.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_29.htm">variable-leng=
th=20
records</A> that contain fixed-field data into a SAS data set, =
there might=20
be values that are shorter than others or that are missing. The <A =
onmouseover=3D"window.status=3D'Display details on the PAD =
option.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_30.htm">PAD =
option</A>=20
pads each record with blanks so that all data lines have the same =
length.=20
</P></TD></TR></TBODY></TABLE></CENTER><!-- 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> </P></TD></TR></TBODY></TABLE><BR></CENTER>
<P align=3Dcenter>
<TABLE cellPadding=3D2 align=3Dcenter>
<TBODY>
<TR>
<TD><FONT color=3D#003399><STRONG>LIBNAME</STRONG> <EM>libref</EM>=20
=
<STRONG>'</STRONG><EM>SAS-data-library</EM><STRONG>';</STRONG></FON=
T></TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG>FILENAME</STRONG> <EM>fileref=20
=
</EM><STRONG>'</STRONG><EM>filename</EM><STRONG>';</STRONG></FONT><=
/TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG>DATA</STRONG>=20
<EM>SAS-data-set</EM><STRONG>;</STRONG></FONT></TD></TR>
<TR>
<TD><FONT color=3D#003399> =20
<STRONG> INFILE</STRONG> <EM>file-specification</EM>=20
<STRONG>;</STRONG></FONT></TD></TR>
<TR>
<TD><NOBR> <STRONG><A=20
onmouseover=3D"window.status=3D'Display details on the INPUT =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_8.htm">INPUT</A>=20
</STRONG><A=20
onmouseover=3D"window.status=3D'Display details on pointer =
controls.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_9.htm"><EM>pointer-co=
ntrol</EM></A><FONT=20
color=3D#003399><EM> variable </EM></FONT><EM><A=20
onmouseover=3D"window.status=3D'Display details on informats.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m19/m19_18.htm">informat.</A>=
</EM>;</NOBR></TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG>RUN; </STRONG></FONT></TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG>PROC PRINT=20
=
DATA=3D</STRONG><EM>SAS-data-set</EM><STRONG>;</STRONG></FONT></TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG>RUN; =
</STRONG></FONT></TD></TR></TBODY></TABLE>
<P align=3Dcenter>
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD align=3Dleft>
<HR>
</TD></TR></TBODY></TABLE><BR></CENTER><!-- InstanceEndEditable -->
<P><!-- InstanceBeginEditable name=3D"sampleprogram" -->
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD align=3Dleft><STRONG><A name=3DSample>Sample =
Program</A></STRONG> <PRE> <FONT color=3D#003399> libname perm =
'c:\data\sales';</FONT>
<FONT color=3D#003399> filename vandata =
'c:\records\vans.dat';</FONT>
<FONT color=3D#003399> data perm.vansales;</FONT>
<FONT color=3D#003399> infile vandata;</FONT>
<FONT color=3D#003399> input +12 Quarter 1. @1 Region $9.</FONT>
<FONT color=3D#003399> +6 TotalSales comma11.;</FONT>
<FONT color=3D#003399>run;</FONT>
<FONT color=3D#003399> proc print data=3Dperm.vansales;</FONT>
<FONT color=3D#003399> run;</FONT></PRE>
<P>
<HR>
</TD></TR></TBODY></TABLE><BR><!-- InstanceEndEditable -->
<P><!-- InstanceBeginEditable name=3D"pointstoremember" -->
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD align=3Dleft><STRONG><A name=3DPoints>Points to =
Remember</A></STRONG>=20
<UL>
<LI>When you use column input or formatted input, the input =
pointer=20
stops on the column following the last column that was =
read.<BR><BR>
<LI>When you use informats, you do not need to specify a =
<EM>d</EM>=20
value if the data values already contain decimal places.<BR><BR>
<LI>Column input can be used to read standard character or =
standard=20
numeric data only.<BR><BR>
<LI>Formatted input can be used to read both standard and =
nonstandard=20
data.<BR><BR>
<LI>When reading variable-length records that contain =
fixed-field data,=20
you can avoid problems by using the PAD option in the INFILE =
statement.=20
</LI></UL></TD></TR></TBODY></TABLE><!-- InstanceEndEditable =
--></CENTER><!-- #BeginLibraryItem "/Library/nav_regular_bottom.lbi" -->
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"100%">
<TBODY>
<TR>
<TD width=3D14><IMG height=3D7 alt=3D""=20
=
src=3D"http://www.sas.com/apps/elearning/images/en/navimages/linebox.gif"=
=20
width=3D14></TD>
<TD colSpan=3D2><IMG height=3D7 alt=3D""=20
=
src=3D"http://www.sas.com/apps/elearning/images/en/navimages/linegray.gif=
"=20
width=3D"100%"></TD></TR>
<TR>
<TD> </TD>
<TD vAlign=3Dtop><FONT face=3D"Verdana, Arial, Helvetica, Sans =
Serif"=20
color=3Dgray size=3D1><A class=3Dcopyrightlink=20
href=3D"javascript:%20openOther('../copyrite.htm')"><FONT=20
face=3D"Arial, Helvetica, sans-serif">Copyright</FONT></A> <FONT=20
face=3D"Arial, Helvetica, sans-serif">=A9 2003 SAS Institute Inc., =
Cary, NC,=20
USA. All rights reserved.</FONT></FONT> <FONT=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -