<?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: Create seperate file for each Name (ID) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232551#M42398</link>
    <description>&lt;P&gt;Use FILEVAR= on the FILE statement to create your csv (example under Windows) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name_ID var1 var2;
datalines;
111 1 2
111 3 6
111 6 9
555 2 2
555 4 5
555 5 4
563 2 2
563 1 1
;

%let path=&amp;amp;sasforum.\Datasets;

data _null_;
set have;
myFilename = cats("&amp;amp;path.\", name_ID, ".csv");
file toto filevar=myFilename dsd;
put var1 var2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 31 Oct 2015 03:46:52 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-10-31T03:46:52Z</dc:date>
    <item>
      <title>Create seperate file for each Name (ID)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232540#M42394</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data with variable nameID as below.&lt;/P&gt;
&lt;P&gt;I want to create separate file for each name AND the NameID colum is &lt;U&gt;deleted&lt;/U&gt; from the final file.&lt;/P&gt;
&lt;P&gt;Then export each file into CSV.&lt;/P&gt;
&lt;P&gt;So the CSV file only contain var1 var2 (in the below dataset)&lt;/P&gt;
&lt;P&gt;There are thousand names and I haven't found a way to do it yet.&lt;/P&gt;
&lt;P&gt;Any help is very much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;input name_ID var1 var2;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;1111 2&lt;/P&gt;
&lt;P&gt;111 3 6&lt;/P&gt;
&lt;P&gt;111 6 9&lt;/P&gt;
&lt;P&gt;555 2 2&lt;/P&gt;
&lt;P&gt;555 4 5&lt;/P&gt;
&lt;P&gt;555 5 4&lt;/P&gt;
&lt;P&gt;563 2 2&lt;/P&gt;
&lt;P&gt;563 1 1&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2015 00:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232540#M42394</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-10-31T00:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create seperate file for each Name (ID)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232547#M42397</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Here is a code that can help.....&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name_ID:$4. var1:$1. var2:$2.;
datalines;
1111 2
111 3 6
111 6 9
555 2 2
555 4 5
555 5 4
563 2 2
563 1 1
;
run;
proc sql;
	 create table t1 as select distinct name_ID from have;
quit;	 
proc print data=t1;
%macro names;
	       data &amp;amp;dsname;set have;where name_id = "&amp;amp;nameid";
%mend names;
data have;
      set t1;
      call symput('nameid',name_id);
      call symput ('dsname',("_"||name_id));
	  call execute ('%names');
run;
proc contents data=work._all_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since the values of the name_id are numbers, I have added an underscore in the beginning to allow SAS to create dataset with Char in the beginning... At the end, here is what it creates... Rows 11-14 is what you are interested in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;#	Name	Member Type	File Size	Last Modified
1	DATA1	DATA	128KB	10/31/2015 01:04:53
2	DATA2	DATA	128KB	10/31/2015 01:06:30
3	DATA3	DATA	128KB	10/31/2015 01:08:38
4	DATA4	DATA	128KB	10/31/2015 01:11:19
5	HAVE	DATA	128KB	10/31/2015 01:23:56
6	NAMEID	DATA	128KB	10/31/2015 01:01:31
7	REGSTRY	ITEMSTOR	32KB	10/31/2015 00:32:05
8	SASGOPT	CATALOG	12KB	10/31/2015 00:32:49
9	SASMAC1	CATALOG	188KB	10/31/2015 00:32:10
10	T1	DATA	128KB	10/31/2015 01:23:55
11	_111	DATA	128KB	10/31/2015 01:23:56
12	_1111	DATA	128KB	10/31/2015 01:23:56
13	_555	DATA	128KB	10/31/2015 01:23:56
14	_563	DATA	128KB	10/31/2015 01:23:56&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope it helps someway.... Good luck...!!!&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2015 04:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232547#M42397</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-10-31T04:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create seperate file for each Name (ID)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232551#M42398</link>
      <description>&lt;P&gt;Use FILEVAR= on the FILE statement to create your csv (example under Windows) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name_ID var1 var2;
datalines;
111 1 2
111 3 6
111 6 9
555 2 2
555 4 5
555 5 4
563 2 2
563 1 1
;

%let path=&amp;amp;sasforum.\Datasets;

data _null_;
set have;
myFilename = cats("&amp;amp;path.\", name_ID, ".csv");
file toto filevar=myFilename dsd;
put var1 var2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 31 Oct 2015 03:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232551#M42398</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-10-31T03:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create seperate file for each Name (ID)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232618#M42408</link>
      <description>&lt;P&gt;Thank you, PG.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input name_ID var1 var2;&lt;BR /&gt;datalines;&lt;BR /&gt;1111 2&lt;BR /&gt;111 3 6&lt;BR /&gt;111 6 9&lt;BR /&gt;555 2 2&lt;BR /&gt;555 4 5&lt;BR /&gt;555 5 4&lt;BR /&gt;563 2 2&lt;BR /&gt;563 1 1&lt;BR /&gt;;&lt;BR /&gt;proc sort data=have;by name_ID; run;&lt;BR /&gt;data _null_;&lt;BR /&gt; set have;&lt;BR /&gt; fname=cats('c:\temp\File_',name_ID,'.csv');&lt;BR /&gt; file dummy filevar=fname dsd;&lt;BR /&gt; put var1 var2 ;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 04:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232618#M42408</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-11-01T04:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create seperate file for each Name (ID)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232619#M42409</link>
      <description>&lt;P&gt;Thank you, Kannad for helping me.&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 04:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-seperate-file-for-each-Name-ID/m-p/232619#M42409</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-11-01T04:06:38Z</dc:date>
    </item>
  </channel>
</rss>

