📄 m22 - understanding data step processing - 45 of 47.mht
字号:
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_8.htm">written =
to the=20
new data set</A> as an observation. The DATA step executes once =
for each=20
record in the input file, unless otherwise directed.=20
<P><STRONG>Diagnosing Errors in the Compilation =
Phase</STRONG><BR>Missing=20
semicolons, misspelled keywords, and invalid options will cause <A =
onmouseover=3D"window.status=3D'Display details on syntax =
errors.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_30.htm">syntax =
errors</A> in the compilation phase. Detected errors are =
underlined and=20
are identified with a number and message in the log. If SAS can =
interpret=20
a syntax error, the DATA step compiles and executes; if SAS cannot =
interpret the error, the DATA step compiles but doesn't execute.=20
<P><STRONG>Diagnosing Errors</STRONG><STRONG> in the Execution=20
Phase</STRONG><BR>Illegal mathematical operations or processing a=20
character variable as numeric will cause <A=20
onmouseover=3D"window.status=3D'Display details on execution-time =
errors.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_31.htm">errors =
in the=20
execution phase</A>. Depending on the type of error, the log might =
show a=20
warning and might include invalid data from the program data =
vector, and=20
the DATA step either stops or continues.=20
<P><STRONG>Testing Your Programs</STRONG><BR>To detect common =
errors and=20
save development time, compile and execute your program without =
creating=20
observations. Specify the <A=20
onmouseover=3D"window.status=3D'Display details on the keyword =
_NULL_.'"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_37.htm">keyword=20
_NULL_</A> as the data set name to view compilation or execution =
errors=20
without creating a data set. Or use the OBS=3D option in the =
INFILE=20
statement to limit the number of observations that are read or =
created=20
during the DATA step. You can also use the <A=20
onmouseover=3D"window.status=3D'Display details on the PUT =
statement.'"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_40.htm">PUT=20
statement</A> to examine variable values and to generate your own =
message=20
in the log. </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
<P>
<BLOCKQUOTE>
<DL>
<DT><FONT color=3D#003399><A=20
onmouseover=3D"window.status=3D'Display information on the =
DATA statement.'"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_2.htm"><STRONG>DATA</=
STRONG></A><A=20
onmouseover=3D"window.status=3D'Display information on the =
keyword _NULL_.'"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_37.htm">=20
<_NULL_|</A><A=20
onmouseover=3D"window.status=3D'Display information on the =
DATA statement.';"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_2.htm"><EM>SAS-data-s=
et</EM>><STRONG>;</STRONG></A></FONT>=20
<DD><FONT color=3D#003399><STRONG><A=20
onmouseover=3D"window.status=3D'Display information on the =
INFILE statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_2.htm">INFILE</A></ST=
RONG><A=20
onmouseover=3D"window.status=3D'Display information on the =
INFILE statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_2.htm">=20
<EM>file-specification </EM></A><A=20
onmouseover=3D"window.status=3D'Display information on the =
OBS=3D system option.'"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_37.htm"><STRONG>OBS=3D=
</STRONG><EM>n</EM></A><A=20
onmouseover=3D"window.status=3D'Display information on the =
INFILE statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_2.htm"><STRONG>;</STR=
ONG></A></FONT>=20
<DD><FONT color=3D#003399><NOBR><A=20
onmouseover=3D"window.status=3D'Display information on the =
INPUT statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_5.htm"><STRONG>INPUT<=
/STRONG><EM>=20
variable-1 informat-1 =
input-pointer-control-1</EM></A></NOBR></FONT>=20
<DD><NOBR> <FONT =
color=3D#003399>=20
<A=20
onmouseover=3D"window.status=3D'Display information on the =
INPUT statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_5.htm"><EM>< . .=20
.variable-n informat-n <BR></EM></A></FONT> =
=20
<FONT color=3D#003399> <A=20
onmouseover=3D"window.status=3D'Display information on the =
INPUT statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_5.htm"><EM>input-poin=
ter-control-n></EM><STRONG>;</STRONG></A></FONT></NOBR>=20
<DD><FONT color=3D#003399></FONT>
<DD><FONT color=3D#003399><A=20
onmouseover=3D"window.status=3D'Display information on the PUT =
statement.'"=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m22/m22_40.htm"><STRONG>PUT</=
STRONG>=20
<EM>specification(s)</EM><STRONG>;</STRONG></A></FONT>=20
<DT><FONT color=3D#003399><STRONG>RUN</STRONG>;</FONT>=20
</DT></DL></BLOCKQUOTE></TD></TR></TBODY></TABLE>
<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 =
Programs</A></STRONG> <PRE><FONT color=3D#003399> data =
perm.update;</FONT>
<FONT color=3D#003399> infile invent;</FONT>
<FONT color=3D#003399> input Item $ 1-13 IDnum $ 15-19</FONT>
<FONT color=3D#003399> InStock 21-22 BackOrd 24-25;</FONT>
<FONT color=3D#003399> Total=3Dinstock+backord;</FONT>
<FONT color=3D#003399> run;</FONT>
<FONT color=3D#003399>data work.test;</FONT>
<FONT color=3D#003399>infile loan;</FONT>
<FONT color=3D#003399>input Code $ 1 Amount 3-10;</FONT>
<FONT color=3D#003399>if code=3D'1' then =
type=3D'variable';</FONT>
<FONT color=3D#003399>else if code=3D'2' then =
type=3D'fixed';</FONT>
<FONT color=3D#003399>else put 'MY NOTE: invalid value: '</FONT>
<FONT color=3D#003399>code=3D;</FONT>
<FONT color=3D#003399>run;</FONT></PRE>
<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><BR>
<UL>
<LI>Making, diagnosing, and resolving errors is part of the =
process of=20
writing programs. However, checking for common errors will save =
you time=20
and trouble. Make sure that<BR><BR>
<UL>
<LI>each SAS statement ends with a semicolon=20
<LI>filenames are spelled correctly=20
<LI>keywords are spelled correctly.<BR><BR></LI></UL>
<LI>In SAS output, missing numeric values are represented by =
periods,=20
and missing character values are left blank.<BR><BR>
<LI>The order in which variables are defined in the DATA step =
determines=20
the order in which the variables are stored in the data =
set.<BR><BR>
<LI>Standard character values can include numbers, but numeric =
values=20
cannot include characters. =
</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"=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -