<?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: Macro for joining tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173942#M33402</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two separate problems here.&lt;/P&gt;&lt;P&gt;1) You are looping over I and J to define the INPUT datasets.&amp;nbsp; And then for a particular input data set you are generating 8 calls to PROC SURVEYSELECT.&amp;nbsp; For each INPUT file you are generating the same 8 output file names.&amp;nbsp; So only the LAST of the INPUT datasets will be used in generating the OUTPUT datasets.&lt;/P&gt;&lt;P&gt;2) You are calling PROC SURVEYSELECT 8 times with the same INPUT dataset and the same input SEED value.&amp;nbsp; So you are re-generating the same "random" sample 8 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you read the manual on PROC SURVEYSELECT?&amp;nbsp; Please look up how to generate 8 samples in one call.&amp;nbsp; That will fix the second problem.&lt;/P&gt;&lt;P&gt;To fix the first problem you probably need to include &amp;amp;I and &amp;amp;J in the name of the OUTPUT dataset (or datasets if you cannot figure out how the proc works).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Feb 2015 03:38:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-02-19T03:38:45Z</dc:date>
    <item>
      <title>Re: Macro for joining tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173937#M33397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your generous help Tom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running a proc surveyselect code with do loops in macro, and having a same problem as I do in my earlier code. The output I'm getting is replaced by the last table. I'm trying to get 8 different sampled tables. I have been trying hard to get it done since yesterday, but no luck yet.Below is the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro samp;&lt;/P&gt;&lt;P&gt;%do i= 2 %to 3;&lt;/P&gt;&lt;P&gt;%do j=03 %to 12 %by 3;&lt;/P&gt;&lt;P&gt;%do k= 1 %to 8;&lt;/P&gt;&lt;P&gt;proc syrveyselect data=data_201&amp;amp;i.%sysfunc(putn(&amp;amp;j.z2)) method=srs sampsize=500 seed=1992 out=sample&amp;amp;k;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend samp&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;%samp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 17:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173937#M33397</guid>
      <dc:creator>koomalkc</dc:creator>
      <dc:date>2015-02-18T17:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for joining tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173938#M33398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please post a new question rather than continue this question. If they're related feel free to link bank to this question or Branch off to a new discussion. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 17:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173938#M33398</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-02-18T17:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for joining tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173939#M33399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your program is making only 8 output files (because there are 8 values of K).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; out=sample&amp;amp;k&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If you want each run to generate a different data set then you have to give them unique names.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 22:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173939#M33399</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-18T22:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for joining tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173940#M33400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not use the features of SURVEYSELECT to make multiple samples in one file instead using macro code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 22:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173940#M33400</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-18T22:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for joining tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173941#M33401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Yes, I want 8 different data set, and I'm getting 8 dataset with the same observations, that is the problem. Isn't that sample1-sample8 are unique names for the output data sets? I'm trying to use SURVEYSELECT to fetch sample form 8 original datasets and want 8 output as a sampled dataset i.e. sample1-sample8 or one single sampled dataset that contains sampled observations from 8 original dataset, either way is good. But I'm getting none of those. I replace out=sample&amp;amp;k with sample without k (omitting counter for k) to make multiple samples in one file as you mentioned, I got one table that is 8th one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm expecting SAS code from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 02:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173941#M33401</guid>
      <dc:creator>koomalkc</dc:creator>
      <dc:date>2015-02-19T02:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for joining tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173942#M33402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two separate problems here.&lt;/P&gt;&lt;P&gt;1) You are looping over I and J to define the INPUT datasets.&amp;nbsp; And then for a particular input data set you are generating 8 calls to PROC SURVEYSELECT.&amp;nbsp; For each INPUT file you are generating the same 8 output file names.&amp;nbsp; So only the LAST of the INPUT datasets will be used in generating the OUTPUT datasets.&lt;/P&gt;&lt;P&gt;2) You are calling PROC SURVEYSELECT 8 times with the same INPUT dataset and the same input SEED value.&amp;nbsp; So you are re-generating the same "random" sample 8 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you read the manual on PROC SURVEYSELECT?&amp;nbsp; Please look up how to generate 8 samples in one call.&amp;nbsp; That will fix the second problem.&lt;/P&gt;&lt;P&gt;To fix the first problem you probably need to include &amp;amp;I and &amp;amp;J in the name of the OUTPUT dataset (or datasets if you cannot figure out how the proc works).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 03:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173942#M33402</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-02-19T03:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for joining tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173943#M33403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have fixed the problem. I was thinking this issue in a more complex way. I replaced output dataset with i and j index, and no using index k. That way the solution was perfect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 15:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Macro-for-joining-tables/m-p/173943#M33403</guid>
      <dc:creator>koomalkc</dc:creator>
      <dc:date>2015-02-19T15:03:34Z</dc:date>
    </item>
  </channel>
</rss>

