⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m27 - reading hierarchical files - 28 of 30.mht

📁 sas的考试样题
💻 MHT
📖 第 1 页 / 共 5 页
字号:
      <P>You can use a <A=20
      onmouseover=3D"window.status=3D'Display details on subsetting IF =
statements.';"=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_8.htm">subsetting IF =

      statement</A> to check for the condition that the record is a =
detail=20
      record. If the record is a detail record, use another INPUT =
statement to=20
      read the variable values in that&nbsp;record.=20
      <P>You can use the <A=20
      onmouseover=3D"window.status=3D'Display details on the DROP=3D =
option.';"=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_8.htm#drop">DROP=3D=20
      option</A> to prevent the variable that identifies each record's =
type from=20
      being included in the data set. =
</P></TD></TR></TBODY></TABLE></CENTER>
<P align=3Dcenter><BR>
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
  <TBODY>
  <TR>
    <TD><STRONG>Creating One Observation per Header Record</STRONG> =
<BR><A=20
      onmouseover=3D"window.status=3D'Display details on creating one =
observation for each header record.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_15.htm">Creating one =

      observation per header record</A> condenses a large amount of =
information=20
      into a concise data set. As you <A=20
      onmouseover=3D"window.status=3D'Display details on writing the =
DATA step.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_16.htm">write =
the DATA=20
      step</A>, you need to think about performing several tasks.=20
      <P>As with creating one observation per detail record, use a <A=20
      onmouseover=3D"window.status=3D'Display details on the RETAIN =
statement.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_16.htm">RETAIN =

      statement</A> to keep the header record as a part of each =
observation=20
      until the next header record is encountered. Then read the field =
in each=20
      record that identifies the record's type. Remember to use the @ =
line-hold=20
      specifier to hold the current record so that the other values in =
the=20
      record can be read.=20
      <P>When the record is a header record, <STRONG>multiple=20
      </STRONG>statements need to be executed. You can do this by adding =
a <A=20
      onmouseover=3D"window.status=3D'Display details on simple DO =
groups.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_17.htm">simple =
DO=20
      group</A> to an IF-THEN statement. Within the DO group, &nbsp;you =
need to=20
      <OL>
        <LI>determine whether this is the <STRONG>first</STRONG> header =
record=20
        in the external file by using the automatic variable <TT>_N_ =
</TT>
        <LI>use an OUTPUT statement to write each header record except =
for the=20
        first one to the data set=20
        <LI>use an assignment statement to create a summary variable, =
and set=20
        its value to <EM>0</EM>=20
        <LI>add an INPUT statement to read the variable values in the =
header=20
        record=20
        <LI>close the loop with an END statement. </LI></OL>
      <P>When the record is&nbsp;a detail record, you need to define an=20
      alternative set of actions. You can do this by adding an <A=20
      onmouseover=3D"window.status=3D'Display details on the ELSE =
statement.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_19.htm">ELSE=20
      statement</A> to an IF-THEN statement. As each detail record is =
read, you=20
      can increment the value of the summary variable by using a sum =
statement.=20
      <P>After the last detail record is read, there are no more header =
records=20
      to cause the last observation to be written to the data set. You =
can=20
      determine when the current record is the last record in an =
external file=20
      by specifying the <A=20
      onmouseover=3D"window.status=3D'Display details on determining the =
END=3D option.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_21.htm">END=3D =
option</A>=20
      in the INFILE statement.=20
      <P>Again, you can use the <A=20
      onmouseover=3D"window.status=3D'Display details on the DROP=3D =
option.';"=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_8.htm#drop">DROP=3D=20
      option</A> to prevent the variable that identifies each record's =
type from=20
      being included in the data set. =
</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>
<P>
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
  <TBODY>
  <TR>
    <TD>
      <BLOCKQUOTE><STRONG>Syntax to Create One Observation for Each =
Detail=20
        Record</STRONG> </BLOCKQUOTE></TD></TR></TBODY></TABLE>
<TABLE cellPadding=3D2>
  <TBODY>
  <TR>
    <TD><FONT color=3D#003399><STRONG>LIBNAME</STRONG> <EM>libref</EM>=20
      =
&nbsp;<STRONG>'</STRONG><EM>SAS-data-library</EM><STRONG>';</STRONG></FON=
T></TD></TR>
  <TR>
    <TD><FONT color=3D#003399><STRONG>FILENAME</STRONG> fileref=20
      =
<EM><STRONG>'</STRONG>filename<STRONG>'</STRONG></EM><STRONG>;</STRONG></=
FONT></TD></TR>
  <TR>
    <TD><FONT =
color=3D#003399><STRONG>DATA=3D</STRONG><EM>SAS-data-set</EM></FONT>=20
      &nbsp;<A=20
      onmouseover=3D"window.status=3D'Display details on the DROP=3D =
option.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_8.htm#drop"><STRONG>(=
DROP=3D</STRONG>=20
      <EM>variable</EM><STRONG>);</STRONG></A></TD></TR>
  <TR>
    <TD><FONT color=3D#003399>&nbsp; &nbsp; <STRONG>&nbsp;=20
      </STRONG></FONT><STRONG><FONT =
color=3D#003399>INFILE</FONT></STRONG><FONT=20
      color=3D#003399> =
<EM>file-specification</EM><STRONG>;</STRONG></FONT></TD></TR>
  <TR>
    <TD><FONT color=3D#003399><STRONG>&nbsp; &nbsp; </STRONG>&nbsp; =
</FONT><A=20
      onmouseover=3D"window.status=3D'Display details on the RETAIN =
statement.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_16.htm"><STRONG>RETAI=
N</STRONG>=20
      <EM>variable</EM><STRONG>;</STRONG></A></TD></TR>
  <TR>
    <TD><FONT color=3D#003399><STRONG>&nbsp; &nbsp; &nbsp;</STRONG> =
</FONT><FONT=20
      color=3D#003399><STRONG>INPUT</STRONG>=20
      <EM>variable</EM><STRONG>;</STRONG></FONT></TD></TR>
  <TR>
    <TD><FONT color=3D#003399><STRONG>&nbsp; &nbsp;&nbsp;=20
      </STRONG>&nbsp;</FONT><NOBR><A=20
      onmouseover=3D"window.status=3D'Display details on the IF-THEN =
statement.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_6.htm"><STRONG>IF</ST=
RONG>=20
      =
<EM>variable</EM><STRONG>=3D'</STRONG><EM>condition</EM><STRONG>'</STRONG=
><STRONG>=20
      THEN </STRONG><EM>SAS =
statement</EM><STRONG>;</STRONG></A></NOBR></TD></TR>
  <TR>
    <TD>&nbsp; &nbsp; &nbsp; <FONT color=3D#003399><STRONG>IF</STRONG>=20
      =
<EM>variable</EM><STRONG>=3D'</STRONG><EM>condition</EM><STRONG>';</STRON=
G></FONT></TD></TR>
  <TR>
    <TD>&nbsp; &nbsp; &nbsp;<FONT=20
      =
color=3D#003399><EM>SAS-statement</EM><STRONG>;</STRONG></FONT></TD></TR>=

  <TR>
    <TD><FONT color=3D#003399><STRONG>RUN;=20
</STRONG></FONT></TD></TR></TBODY></TABLE></CENTER>
<P align=3Dcenter>
<CENTER>
<TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"85%" border=3D0>
  <TBODY>
  <TR>
    <TD align=3Dleft>
      <BLOCKQUOTE><STRONG>Syntax to Create One Observation for Each =
Header=20
        Record</STRONG> </BLOCKQUOTE></TD></TR></TBODY></TABLE>
<TABLE cellPadding=3D2>
  <TBODY>
  <TR>
    <TD><FONT color=3D#003399><STRONG>LIBNAME</STRONG> <EM>libref</EM>=20
      =
&nbsp;<STRONG>'</STRONG><EM>SAS-data-library</EM><STRONG>';</STRONG></FON=
T></TD></TR>
  <TR>
    <TD><FONT color=3D#003399><STRONG>FILENAME </STRONG>fileref=20
      <EM>'filename'</EM><STRONG>;</STRONG></FONT></TD></TR>
  <TR>
    <TD><FONT =
color=3D#003399><STRONG>DATA=3D</STRONG><EM>SAS-data-set</EM></FONT>=20
      &nbsp;<A=20
      onmouseover=3D"window.status=3D'Display details on the DROP=3D =
option.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_8.htm#drop"><STRONG>(=
DROP=3D</STRONG>=20
      <EM>variable</EM><STRONG>);</STRONG></A></TD></TR>
  <TR>
    <TD><FONT color=3D#003399>&nbsp; &nbsp; &nbsp; </FONT><FONT=20
      color=3D#003399><STRONG>INFILE</STRONG> =
<EM>file-specification</EM>=20
      </FONT><A=20
      onmouseover=3D"window.status=3D'Display details on determining the =
END=3D option.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20
      =
href=3D"http://www.sas.com/apps/OLTRN/59080/m27/m27_21.htm"><STRONG>END=3D=
</STRONG><EM>variable</EM><STRONG>;</STRONG></A></TD></TR>
  <TR>
    <TD><FONT color=3D#003399><STRONG>&nbsp; &nbsp; </STRONG>&nbsp; =
</FONT><A=20
      onmouseover=3D"window.status=3D'Display details on the RETAIN =
statement.'; "=20
      onclick=3DsuggestBack() onmouseout=3D"window.status=3D''"=20

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -