<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why there is only one obs per header record output to the data set instead of outputting all obs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408344#M99649</link>
    <description>Ok it does help me a lot !!thank you</description>
    <pubDate>Sun, 29 Oct 2017 13:20:15 GMT</pubDate>
    <dc:creator>bimohkc</dc:creator>
    <dc:date>2017-10-29T13:20:15Z</dc:date>
    <item>
      <title>Why there is only one obs per header record output to the data set instead of outputting all obs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408330#M99638</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data summary;
infile 'D:\SASdatafile\survey.txt' dlm=',';
input Household_ID: $10. Type $ no_of_members @;
no_of_males=0;
no_of_females=0;
no_of_employed=0;
household_income=0;
do index=1 to no_of_members;
input Household_Mem_No H_indicator$ DOB: date9. Gender $ M_Status $ E_level E_status $ M_income @;
if Gender ='M' then no_of_males +1;
else no_of_females +1;
if E_status = 'FT' or E_status = 'PT' then no_of_employed+1;
if H_indicator='Y' then Age_Householder=yrdif(dob,'30dec2008'd,'Actual');
Age_Householder=round(Age_Householder,0.5);
household_income +M_income;
end;
average_income=Household_income/no_of_members;
average_income=round(average_income,0.01);
keep Household_ID type no_of_males no_of_females no_of_employed Age_Householder average_income ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The data of survey.txt is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A123456789,A,3
1,Y,15Feb1960,M,M,3,FT,55000
2,N,3Jun1965,F,M,3,UE,0
3,N,24Jan1988,M,S,2,NA,3000
A135790234,B,1
1,Y,19Oct1944,F,D,0,NA,3000
B234523456,A,2
1,Y,30Jun1978,F,M,1,PT,4000
2,N,21May1975,M,M,2,FT,30000&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 29 Oct 2017 11:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408330#M99638</guid>
      <dc:creator>bimohkc</dc:creator>
      <dc:date>2017-10-29T11:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why there is only one obs per header record output to the data set instead of outputting all obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408337#M99643</link>
      <description>&lt;P&gt;Not sure precisely what you are asking, but the structure of your code suggests to me that you might want an OUTPUT statement before your END statement in your DO loop.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 12:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408337#M99643</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-29T12:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why there is only one obs per header record output to the data set instead of outputting all obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408338#M99644</link>
      <description>What will be the effect of adding an OUTPUT statement? Is it possible to output all the detail records?</description>
      <pubDate>Sun, 29 Oct 2017 12:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408338#M99644</guid>
      <dc:creator>bimohkc</dc:creator>
      <dc:date>2017-10-29T12:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why there is only one obs per header record output to the data set instead of outputting all obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408339#M99645</link>
      <description>It will write each time you read.  Try it and see if that is what you want.</description>
      <pubDate>Sun, 29 Oct 2017 12:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408339#M99645</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-29T12:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why there is only one obs per header record output to the data set instead of outputting all obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408340#M99646</link>
      <description>It works. But can you briefly explain how the record will be changed in each iteration of the first record?thanks a lot.</description>
      <pubDate>Sun, 29 Oct 2017 13:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408340#M99646</guid>
      <dc:creator>bimohkc</dc:creator>
      <dc:date>2017-10-29T13:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why there is only one obs per header record output to the data set instead of outputting all obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408343#M99648</link>
      <description>&lt;P&gt;Here is a sketch of a typical data step;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ...;&lt;/P&gt;
&lt;P&gt;infile ...;&lt;/P&gt;
&lt;P&gt;input ...;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looping is implicit and there is an implicit execution of an OUTPUT before the run (one for each input obs read).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did this, which is perfectly valid.&lt;/P&gt;
&lt;P&gt;data ....;&lt;/P&gt;
&lt;P&gt;infile ....;&lt;/P&gt;
&lt;P&gt;do ....;&lt;/P&gt;
&lt;P&gt;input ...;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read many write one.&amp;nbsp; There is still one implicit output.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Since you said that something was missing, I thought you might want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ....;&lt;/P&gt;
&lt;P&gt;infile ....;&lt;/P&gt;
&lt;P&gt;do ....;&lt;/P&gt;
&lt;P&gt;input ...;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;write each time you read by using an explicit OUTPUT;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 13:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408343#M99648</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-29T13:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why there is only one obs per header record output to the data set instead of outputting all obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408344#M99649</link>
      <description>Ok it does help me a lot !!thank you</description>
      <pubDate>Sun, 29 Oct 2017 13:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408344#M99649</guid>
      <dc:creator>bimohkc</dc:creator>
      <dc:date>2017-10-29T13:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why there is only one obs per header record output to the data set instead of outputting all obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408375#M99665</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Why there is only one obs per header record output to the data set instead of outputting all obs?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because you read the entire household in one pass of the data step.&lt;/P&gt;
&lt;P&gt;Since you are only keeping household level variables why would you want it to output more than one observation per household?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 18:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-there-is-only-one-obs-per-header-record-output-to-the-data/m-p/408375#M99665</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-29T18:07:04Z</dc:date>
    </item>
  </channel>
</rss>

