📄 m26 - creating multiple observations from a single record - 31 of 33.mht
字号:
with a specified format=20
<LI>write the first block of values as an observation=20
<LI>execute the DATA step until all repeating blocks have been =
read.=20
</LI></OL>
<P><STRONG>Reading the Same Number of Repeating =
Fields<BR></STRONG>To=20
create multiple observations from a record that contains an ID =
field and=20
the same number of repeating fields, you must execute the DATA =
step once=20
for each record, repetitively reading and writing values in one =
iteration.=20
The DATA step should include statements that=20
<OL>
<LI>read the ID field and <A=20
onmouseover=3D"window.status=3D'Display details on holding the =
current record.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_3.htm">hold =
the=20
current record</A> with the <A=20
onmouseover=3D"window.status=3D'Display details on the @ =
line-hold specifier'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_13.htm">http://www.sa=
s.com/apps/OLTRN/59080/m26/m26_13.htm</A>=20
line-hold specifier=20
<LI>execute SAS statements using an <A=20
onmouseover=3D"window.status=3D'Display details on iterative DO =
loops.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_16.htm">iterative DO =
loop</A>. The iterative DO loop repetitively processes =
statements that=20
<UL>
<LI>read the next value of the repeating field and hold the =
record=20
with the @ line-hold specifier=20
<LI>explicitly write an observation to the data set by using =
an <A=20
onmouseover=3D"window.status=3D'Display details on the OUTPUT =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_16.htm">OUTPUT=20
statement</A>. </LI></UL>
<LI>complete the iterative DO loop with an END statement. =
</LI></OL>
<P><STRONG>Reading a Varying Number of Repeating =
Fields</STRONG><BR>To=20
create multiple observations from a record that contains an ID =
field and a=20
varying number of repeating fields, you must execute the DATA step =
once=20
for each record, repetitively reading and writing values in one =
iteration=20
while the value of the repeating field exists. The DATA step =
should=20
include statements that=20
<OL>
<LI>prevent SAS from reading the next record if missing values =
were=20
encountered in the current record by using the <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/m26/m26_23.htm">MISSOVER=20
option</A>=20
<LI>read the ID field and the first repeating field, and then <A =
onmouseover=3D"window.status=3D'Display details on holding the =
current record.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_13.htm">hold =
the=20
record</A> with the single trailing at sign (@) line-hold =
specifier=20
<LI>optionally <A=20
onmouseover=3D"window.status=3D'Display details on creating a =
counter variable.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_26.htm">create a=20
counter variable</A>=20
<LI><A=20
onmouseover=3D"window.status=3D'Display details on executing SAS =
statements while a condition is true.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_24.htm">execute SAS=20
statements while a condition is true</A>, using a DO WHILE loop. =
A DO=20
WHILE loop repetitively processes statements that=20
<UL>
<LI>optionally increment the value of the counter variable by =
using a=20
<A=20
onmouseover=3D"window.status=3D'Display details on the SUM =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_26.htm">sum=20
statement</A>=20
<LI>explicitly add an observation to the data set by using an =
<A=20
onmouseover=3D"window.status=3D'Display details on the OUTPUT =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_16.htm">OUTPUT=20
statement</A>=20
<LI><A=20
onmouseover=3D"window.status=3D'Display details on reading the =
next value.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_27.htm">read the=20
next value</A> of the repeating field and hold the record with =
the=20
single trailing at sign (@) line-hold specifier. </LI></UL>
<LI>complete the DO WHILE loop with an END statement.=20
</LI></OL></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> </P></TD></TR></TBODY></TABLE>
<CENTER><BR></CENTER></CENTER>
<P align=3Dcenter>
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
<TBODY>
<TR>
<TD align=3Dleft>
<BLOCKQUOTE>
<P><STRONG>Repeating Blocks of=20
Data</STRONG></P></BLOCKQUOTE></TD></TR></TBODY></TABLE><BR></CENTER>
<P>
<TABLE cellPadding=3D2>
<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> =
<STRONG>INFILE</STRONG>=20
<EM>file-specification</EM><STRONG>;</STRONG></FONT></TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG> </STRONG> <A=20
onmouseover=3D"window.status=3D'Display details on the @@ =
line-hold specifier.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_4.htm"><STRONG>INPUT<=
/STRONG>=20
<EM>variables =
<STRONG>@@</STRONG></EM><STRONG>;</STRONG></A></FONT></TD></TR>
<TR>
<TD><NOBR><FONT color=3D#003399><STRONG> =
</STRONG> <A=20
onmouseover=3D"window.status=3D'Display details on the FORMAT =
statement.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_6.htm"><STRONG>FORMAT=
</STRONG>=20
<EM>date/time-variable=20
format</EM><STRONG>;</STRONG></A></FONT></NOBR></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>
<BLOCKQUOTE>
<P><STRONG>An ID Field Followed by the Same Number of Repeating=20
=
Fields</STRONG></P></BLOCKQUOTE></TD></TR></TBODY></TABLE><BR></CENTER>
<P align=3Dcenter>
<CENTER>
<TABLE cellPadding=3D2>
<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> <STRONG>INFILE=20
=
</STRONG><EM>file-specification</EM><STRONG>;</STRONG></FONT></TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG> </STRONG> <A=20
onmouseover=3D"window.status=3D'Display details on the @ line-hold =
specifier.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_13.htm"><STRONG>INPUT=
=20
</STRONG><EM>id-variable=20
<STRONG>@</STRONG></EM><STRONG>;</STRONG></A></FONT></TD></TR>
<TR>
<TD><FONT color=3D#003399><STRONG> </STRONG> <A=20
onmouseover=3D"window.status=3D'Display details on executing SAS =
statements using a DO loop.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
href=3D"http://www.sas.com/apps/OLTRN/59080/m26/m26_16.htm"><STRONG>DO</S=
TRONG>=20
<EM>index-variable =
specification</EM><STRONG>;</STRONG></A></FONT></TD></TR>
<TR>
<TD><NOBR><FONT color=3D#003399><STRONG> =
</STRONG> =20
<STRONG> <A=20
onmouseover=3D"window.status=3D'Display details on the @ line-hold =
specifier.'; "=20
onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -