<?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: A little help with a macro variable needed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/A-little-help-with-a-macro-variable-needed/m-p/211946#M39203</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much! You are the best!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jun 2015 13:57:46 GMT</pubDate>
    <dc:creator>Flexymt</dc:creator>
    <dc:date>2015-06-23T13:57:46Z</dc:date>
    <item>
      <title>A little help with a macro variable needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-little-help-with-a-macro-variable-needed/m-p/211944#M39201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just need a little bit help with some macro coding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a random sample of 30 observations from the full dataset of 21000. The first code you see is where i create a macro variable for each of the 30 observations from the sample. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;proc sql noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;select X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;into :X1-X30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;from DatasetSample;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second code is posted below. The point of this loop macro variable is to create 30 unique datasets by using the values from the macro variables X1-X30. &lt;BR /&gt;The problem arises in the "where" statement. For the first loop i want the where statement to look like : X=X1, for the second loop i want it to look like X=X2 and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;%macro sql(n)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;%do r=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Company&amp;amp;r as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from DatasetTotal&lt;/P&gt;&lt;P&gt;where X=&amp;amp;X&amp;amp;r;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This code right here doesnt work. By inserting n=30 i thought the loop would automically assume X=X1, X=X2, X=3 and so on*/&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;% SQL(30)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any tips or help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 07:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-little-help-with-a-macro-variable-needed/m-p/211944#M39201</guid>
      <dc:creator>Flexymt</dc:creator>
      <dc:date>2015-06-23T07:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: A little help with a macro variable needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-little-help-with-a-macro-variable-needed/m-p/211945#M39202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try changing &amp;amp;X&amp;amp;r to &amp;amp;&amp;amp;X&amp;amp;r. Should do the trick.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 13:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-little-help-with-a-macro-variable-needed/m-p/211945#M39202</guid>
      <dc:creator>JonasE</dc:creator>
      <dc:date>2015-06-23T13:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: A little help with a macro variable needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-little-help-with-a-macro-variable-needed/m-p/211946#M39203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much! You are the best!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 13:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-little-help-with-a-macro-variable-needed/m-p/211946#M39203</guid>
      <dc:creator>Flexymt</dc:creator>
      <dc:date>2015-06-23T13:57:46Z</dc:date>
    </item>
  </channel>
</rss>

