<?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: PROC EXPORT-Observations in Dset to Tabs in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124756#M34271</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are many ways and I'm sure others will suggest some but ODS is a simple way. Cynthia posted a solution about that on here in the past few weeks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This paper covers one way though using ODS if you don't mind the XML file as an output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=sashelp.class out=class; by sex; run;&lt;/P&gt;&lt;P&gt;ods tagsets.excelxp file='C:\temp\sample_out.xls';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=class;&lt;/P&gt;&lt;P&gt;by sex;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods tagsets.excelxp close;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Sep 2012 18:30:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2012-09-18T18:30:39Z</dc:date>
    <item>
      <title>PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124755#M34270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ExcelHi Team.&lt;/P&gt;&lt;P&gt;I have a dataset with approx 14000 rows(these 14000) records have info about 25 patients only.....&lt;/P&gt;&lt;P&gt;For example You can say approc that each patient has 14000/25 records .&lt;/P&gt;&lt;P&gt;Each patient has an unique ID&lt;/P&gt;&lt;P&gt;How can I export each patients information to seperate TAB in Excel.&lt;/P&gt;&lt;P&gt;Could anyone help me with the code please.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know the code for exporting datasets to Excel Tabs.......I am confused with the current situation....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 18:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124755#M34270</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-18T18:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124756#M34271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are many ways and I'm sure others will suggest some but ODS is a simple way. Cynthia posted a solution about that on here in the past few weeks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This paper covers one way though using ODS if you don't mind the XML file as an output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=sashelp.class out=class; by sex; run;&lt;/P&gt;&lt;P&gt;ods tagsets.excelxp file='C:\temp\sample_out.xls';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=class;&lt;/P&gt;&lt;P&gt;by sex;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods tagsets.excelxp close;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 18:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124756#M34271</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-09-18T18:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124757#M34272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are the IDs numeric or character?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 18:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124757#M34272</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-18T18:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124758#M34273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you can try to modify(the red parts only) the sample code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;&amp;nbsp; select distinct &lt;SPAN style="color: #ff0000;"&gt;sex&lt;/SPAN&gt; into :Ids separated by ' ' from &lt;SPAN style="color: #ff0000;"&gt;sashelp.class&lt;/SPAN&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname &lt;SPAN style="color: #ff0000;"&gt;&lt;SPAN style="color: #000000;"&gt;test&lt;/SPAN&gt; "c:\temp\forum\tete.xls";&lt;/SPAN&gt;&lt;BR /&gt;%macro test;&lt;BR /&gt; %do i=1 %to %sysfunc(countw(&amp;amp;ids));&lt;BR /&gt; %let dsn=%sysfunc(scan(&amp;amp;ids,&amp;amp;i));&lt;BR /&gt; data test.&amp;amp;dsn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set &lt;SPAN style="color: #ff0000;"&gt;sashelp.class&lt;/SPAN&gt;(where=(&lt;SPAN style="color: #ff0000;"&gt;sex&lt;/SPAN&gt;="&amp;amp;dsn"));&lt;BR /&gt; run;&lt;BR /&gt; %end;&lt;BR /&gt; %mend test;&lt;BR /&gt; %test&lt;/P&gt;&lt;P&gt;libname test clear;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 19:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124758#M34273</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-18T19:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124759#M34274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its one way, you need to run both parts.&lt;/P&gt;&lt;P&gt;The SQL creates the list of by variables to loop over and export one at a time in the macro below.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 19:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124759#M34274</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-09-18T19:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124760#M34275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm curious as to why you can't use SQL?&lt;/P&gt;&lt;P&gt;You can still do it, but it takes much more work...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 19:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124760#M34275</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-09-18T19:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124761#M34276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this one:&lt;/P&gt;&lt;P&gt;proc sort data=sashelp.class(keep=sex) out=class nodupkey;&lt;BR /&gt;by sex;&lt;BR /&gt;/* create macro variables */&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set class end=last ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call symputx(cats('id',_n_),sex);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if last then call symputx('n',_n_);&lt;/P&gt;&lt;P&gt;/* delete the file in case you run the code more than once */&lt;BR /&gt;FILENAME MyFile "C:\temp\forum\tete.xls"&amp;nbsp; ;&lt;BR /&gt;&amp;nbsp; DATA _NULL_ ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = FDELETE('MyFile') ;&lt;BR /&gt;&amp;nbsp; RUN ;&lt;BR /&gt;FILENAME MyFile CLEAR ;&lt;/P&gt;&lt;P&gt;libname test "c:\temp\forum\tete.xls";&lt;/P&gt;&lt;P&gt;%macro test;&lt;BR /&gt; %do i=1 %to &amp;amp;n;&lt;BR /&gt; %let dsn=&amp;amp;&amp;amp;id&amp;amp;i;&lt;BR /&gt; data test.&amp;amp;dsn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set sashelp.class(where=(sex="&amp;amp;dsn"));&lt;BR /&gt; run;&lt;BR /&gt; %end;&lt;BR /&gt; %mend test;&lt;BR /&gt; %test&lt;/P&gt;&lt;P&gt; libname test clear;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 20:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124761#M34276</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-18T20:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124762#M34277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if your id variable is numeric then&lt;/P&gt;&lt;P&gt;data test.&amp;amp;dsn;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sashelp.class(where=(sex="&amp;amp;dsn"));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;would be:&lt;/P&gt;&lt;P&gt;data test.&amp;amp;dsn;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sashelp.class(where=(sex=&amp;amp;dsn));&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The " " is not needed when compare numeric variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the codes below delete the excel file if it already exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FILENAME MyFile "C:\temp\forum\tete.xls"&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DATA _NULL_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = FDELETE('MyFile') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN ;&lt;/P&gt;&lt;P&gt;FILENAME MyFile CLEAR ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Sep 2012 20:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124762#M34277</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-18T20:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124763#M34278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi LInlin,&lt;/P&gt;&lt;P&gt;I tried to apply your code.But I got confused about what to put on the id?&amp;nbsp; leave it like that?&lt;/P&gt;&lt;P&gt;My unique variable which identifies patient is bill number this time....&lt;/P&gt;&lt;P&gt;could you also explain me the callsymput step and the bottom macro please???&lt;/P&gt;&lt;P&gt;dsn=&amp;amp;&amp;amp;id&amp;amp;i; -------i dint get that too&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=&lt;STRONG&gt;MyDATASET&lt;/STRONG&gt;(keep=bill_no) out=&lt;STRONG&gt;classify&lt;/STRONG&gt; nodupkey;&lt;BR /&gt;by bill_no;&lt;BR /&gt;run;&lt;BR /&gt;/* create macro variables */&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set &lt;STRONG&gt;classify&lt;/STRONG&gt; end=last ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call symputx(cats('id',_n_),&lt;STRONG&gt;bill_no&lt;/STRONG&gt;);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if last then call symputx('n',_n_);&lt;/P&gt;&lt;P&gt;/* delete the file in case you run the code more than once */&lt;/P&gt;&lt;P&gt;FILENAME MyFile "C:\Data\Projects\sample_out.xls"&amp;nbsp; ; &lt;BR /&gt;&amp;nbsp; DATA _NULL_ ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc = FDELETE('MyFile') ;&lt;BR /&gt;&amp;nbsp; RUN ;&lt;BR /&gt;FILENAME MyFile CLEAR ;&lt;/P&gt;&lt;P&gt;libname test "C:\Data\Projects\sample_out.xls";&lt;BR /&gt;%macro test;&lt;BR /&gt; %do i=1 %to &amp;amp;n;&lt;BR /&gt; %let dsn=&amp;amp;&amp;amp;id&amp;amp;i;&lt;BR /&gt; data test.&amp;amp;dsn;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set &lt;STRONG&gt;MyDATASET&lt;/STRONG&gt;(where=(bill_no="&amp;amp;dsn"));&lt;BR /&gt; run;&lt;BR /&gt; %end;&lt;BR /&gt; %mend test;&lt;BR /&gt; %test&lt;BR /&gt;libname test clear;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Sep 2012 13:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124763#M34278</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-19T13:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124764#M34279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I have had enough of discussion on this code but I feel I still lack some understanding .&lt;/P&gt;&lt;P&gt;in the final macro step we set sashelp.class and requested the condition(where sex="&amp;amp;dsn");&lt;/P&gt;&lt;P&gt;&amp;amp;dsn gets resoved to id1 and&amp;nbsp; id2 according to the steps done above the macro.&lt;/P&gt;&lt;P&gt;So MY QUESTION IS THAT" WE DONT HAVE A VALUE id1 and id2 so on .........under the variable sex in sashelp.class.&lt;/P&gt;&lt;P&gt;Can someone help me understand???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 15:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124764#M34279</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2012-09-21T15:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT-Observations in Dset to Tabs</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124765#M34280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;id1 and id2 are not variable values. They are macro variables. &amp;amp;id1 =F, &amp;amp;id2=M.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 15:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-EXPORT-Observations-in-Dset-to-Tabs/m-p/124765#M34280</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-21T15:42:04Z</dc:date>
    </item>
  </channel>
</rss>

