<?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: Change dataset with loop count into append statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498387#M132434</link>
    <description>&lt;P&gt;You can, but you still need both the PROC IMPORT and the DATA step first.&amp;nbsp; For example, in PROC IMPORT, re-use the same data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import out=temp ......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in the DATA step, modify it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp (drop= .... same as before ...,.);&lt;/P&gt;
&lt;P&gt;set temp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;..... same as before .....;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then add it to a master data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc append data=temp base=master;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This change relies on the DATA step logic accurately guaranteeing the same structure for all the data sets.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Sep 2018 13:09:16 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-09-24T13:09:16Z</dc:date>
    <item>
      <title>Change dataset with loop count into append statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498275#M132369</link>
      <description>&lt;P&gt;TOPIC: Change dataset with loop count into append statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro that will loop and create a new dataset with a counter behind.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code like this:&lt;/P&gt;&lt;PRE&gt;PROC IMPORT OUT=WORK.out&amp;amp;i  DATAFILE= "&amp;amp;dir/&amp;amp;name" 			
		/*excelout*/			
            DBMS=csv REPLACE;					
			delimiter='09'x;		
			getnames=no;		
		RUN;		

data test&amp;amp;i (drop=			
		%do k=1 %to &amp;amp;cnt;			
		&amp;amp;&amp;amp;col&amp;amp;k..			
		%end;			
		);	
			
		length station $10 voltage $10 year 8 month $20 transformer $10			
		Day $20 Date Time MW_Imp MW_Exp MVAR_Imp MVAR_Exp MVA Power_Factor 8;			
		format Time hhmm.;			
		set out&amp;amp;i. end=last;	&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently the script will generate about 4 data sets if i have 4 external files by PROC IMPORT.&lt;/P&gt;&lt;P&gt;What i want is to eliminate the creation of multiple datasets but just append them into the master file. Is there a way to do so?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 03:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498275#M132369</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-24T03:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Change dataset with loop count into append statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498277#M132371</link>
      <description>&lt;P&gt;Yes, if you read your data as text files. The infile statement can accept multiple file names. The files&amp;nbsp;are simply read in sequence. Check the documentation for the infile statement.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 03:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498277#M132371</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-24T03:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Change dataset with loop count into append statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498387#M132434</link>
      <description>&lt;P&gt;You can, but you still need both the PROC IMPORT and the DATA step first.&amp;nbsp; For example, in PROC IMPORT, re-use the same data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import out=temp ......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in the DATA step, modify it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data temp (drop= .... same as before ...,.);&lt;/P&gt;
&lt;P&gt;set temp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;..... same as before .....;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then add it to a master data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc append data=temp base=master;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This change relies on the DATA step logic accurately guaranteeing the same structure for all the data sets.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 13:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498387#M132434</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-24T13:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Change dataset with loop count into append statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498435#M132455</link>
      <description>&lt;P&gt;If your files are csv with the same structure you can read it in a single step and avoid a macro which is the better approach. PROC IMPORT may truncate records so I wouldn't recommend it either in a situation like this.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 15:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-dataset-with-loop-count-into-append-statement/m-p/498435#M132455</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-24T15:17:21Z</dc:date>
    </item>
  </channel>
</rss>

