<?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: how to save more than 1 macro variables together in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293524#M61104</link>
    <description>&lt;P&gt;Thanks Reeza, but there are errors for '%' in code shown as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;22&lt;/P&gt;
&lt;P&gt;200&lt;/P&gt;
&lt;P&gt;WARNING: Apparent invocation of macro UPPER not resolved.&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;/P&gt;
&lt;P&gt;a missing value, (, +, -, BTRIM, CALCULATED, CASE, EXISTS, INPUT, NOT, PUT, SUBSTRING, TRANSLATE, USER, ^, ~.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2016 18:30:07 GMT</pubDate>
    <dc:creator>michellel</dc:creator>
    <dc:date>2016-08-23T18:30:07Z</dc:date>
    <item>
      <title>how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293489#M61085</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a question about saving more than 1 macro variables at the same time. I have 80 files merged_1, merged_2,....., merged_80. I want to count how many observations for each file, and save the number for each file for further use. Thank you in advance for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I have only 1 file merged_1, I will write codes as below and it works.&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select count(student_id) into: obs_num&lt;/P&gt;
&lt;P&gt;from merged_1;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;obs_num.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I have 80 files. I tried the following codes, but it does not work.&lt;/P&gt;
&lt;P&gt;%macro boots;&lt;/P&gt;
&lt;P&gt;%do i = 1 %to 80;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select count(student_id) into: &lt;FONT color="#ff0000"&gt;obs_num_&amp;amp;i&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;from merged_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &lt;FONT color="#ff0000"&gt;&amp;amp;obs_num_&amp;amp;i;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;%boots;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, Astounding! That works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a follow up question about how to use that macro variable. Thank you in advance for your answer!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use bootstrap to run 1,000 times with replacement for each of 80 files. The count of observation for each file is different, saved in that macro variable &lt;FONT color="#ff0000"&gt;&amp;amp;&amp;amp;obs_num_&amp;amp;i. &lt;/FONT&gt;So basically, for example, if merge_1 has 200 obs, then I want to create 1000 files, each of which has 200 obs, sampled from merge_1 with replacement. (My final target is to calculate mean and s.d. for each of 1000 files&amp;nbsp;per each of 80 files. This part does not include in the following code.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is shown below. It has error for the macro variable &lt;FONT face="Courier New"&gt;&amp;amp;&amp;amp;obs_num_&amp;amp;i. The error shows below as an example for each of variables generated. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;50 &amp;amp;obs_num_1&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;22&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference OBS_NUM_1 not resolved.&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;/P&gt;
&lt;P&gt;2 The SAS System 14:01 Tuesday, August 23, 2016&lt;/P&gt;
&lt;P&gt;a missing value, INPUT, PUT.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;boots2&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*will change 2 to 80*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; j = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;3&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*will change 3 to 1000*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;data select_&amp;amp;i._&amp;amp;j;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; do sel = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;&amp;amp;obs_num_&amp;amp;i;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; rn = ranuni(&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;j.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;100000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; + &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;20151102&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; id = round(rn * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;100000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=select_&amp;amp;i._&amp;amp;j;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;data merged_fnl_&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i._&amp;amp;j&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; merge merged_&amp;amp;i(in=a) select_&amp;amp;i._&amp;amp;j&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(in=b);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if b;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;boots2&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293489#M61085</guid>
      <dc:creator>michellel</dc:creator>
      <dc:date>2016-08-23T18:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293491#M61086</link>
      <description>&lt;P&gt;You got it right except for one small detail.&amp;nbsp; You need another ampersand in the %PUT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;&amp;amp;obs_num_&amp;amp;i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's the only issue that I see here.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 17:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293491#M61086</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-23T17:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293503#M61093</link>
      <description>&lt;P&gt;But...better yet, you can query sashelp.vtable to get these results.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table table_count as
select v.memname, v.libname, v.nobs
from sashelp.vtable as v
where libname='WORK' and %upper(memname) like 'MERGED_%';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 17:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293503#M61093</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-23T17:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293522#M61102</link>
      <description>&lt;P&gt;Thanks, Astounding! That works. I have a follow up question about how to use that macro variable. Thank you in advance for your answer!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use bootstrap to run 1,000 times with replacement for each of 80 files. The count of observation for each file is different, saved in that macro variable &lt;FONT color="#ff0000"&gt;&amp;amp;&amp;amp;obs_num_&amp;amp;i. &lt;/FONT&gt;So basically, for example, if merge_1 has 200 obs, then I want to create 1000 files, each of which has 200 obs, sampled from merge_1 with replacement. (My final target is to calculate mean and s.d. for each of 1000 files&amp;nbsp;per each of 80 files. This part does not include in the following code.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is shown below. It has error for the macro variable &lt;FONT face="Courier New"&gt;&amp;amp;&amp;amp;obs_num_&amp;amp;i. The error shows below as an example for each of variables generated. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;50 &amp;amp;obs_num_1&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;22&lt;/P&gt;
&lt;P&gt;WARNING: Apparent symbolic reference OBS_NUM_1 not resolved.&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;/P&gt;
&lt;P&gt;2 The SAS System 14:01 Tuesday, August 23, 2016&lt;/P&gt;
&lt;P&gt;a missing value, INPUT, PUT.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;boots2&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*will change 2 to 80*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; j = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;3&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*will change 3 to 1000*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;data select_&amp;amp;i._&amp;amp;j;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; do sel = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;&amp;amp;obs_num_&amp;amp;i;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; rn = ranuni(&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;j.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;100000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; + &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;20151102&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; id = round(rn * &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;100000&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=select_&amp;amp;i._&amp;amp;j;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;data merged_fnl_&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i._&amp;amp;j&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; merge merged_&amp;amp;i(in=a) select_&amp;amp;i._&amp;amp;j&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(in=b);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if b;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;boots2&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293522#M61102</guid>
      <dc:creator>michellel</dc:creator>
      <dc:date>2016-08-23T18:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293524#M61104</link>
      <description>&lt;P&gt;Thanks Reeza, but there are errors for '%' in code shown as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;22&lt;/P&gt;
&lt;P&gt;200&lt;/P&gt;
&lt;P&gt;WARNING: Apparent invocation of macro UPPER not resolved.&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;/P&gt;
&lt;P&gt;a missing value, (, +, -, BTRIM, CALCULATED, CASE, EXISTS, INPUT, NOT, PUT, SUBSTRING, TRANSLATE, USER, ^, ~.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293524#M61104</guid>
      <dc:creator>michellel</dc:creator>
      <dc:date>2016-08-23T18:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293527#M61106</link>
      <description>&lt;P&gt;When SQL creates a macro variable, it always uses the local symbol table.&amp;nbsp; Once %BOOTS finishes, all those macro variables are erased.&amp;nbsp; A simple solution would be to change the definition of %BOOTS by adding the line in &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do i=1 %to 80;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;%global obs_num_&amp;amp;i;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That way, a global variable will exist that SQL can utilize.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293527#M61106</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-23T18:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293528#M61107</link>
      <description>&lt;P&gt;It should be UPCASE not UPPER, I always mix the two up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table table_count as
select v.memname, v.libname, v.nobs
from sashelp.vtable as v
where libname='WORK' and %upper(memname) like 'MERGED_%';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 18:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293528#M61107</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-23T18:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293543#M61114</link>
      <description>&lt;P&gt;Thanks Astounding! It works after adding that line, but I found another problem, which is the random number generated in variable 'id'. I plan to generate random numbers, which are less than the count of observation for each file. For example, if merge_1 has 200 observation, I want all random numbers in variable 'id' &amp;lt;200, for example maybe 2 4s,&amp;nbsp;3 198s, and so on. So that when merge back with merge_1 file, I could get randomly selected rows with replacement from the original merge_1 file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result for random numbers in variable 'id' from My code are&amp;nbsp;not limited&amp;nbsp;up to the count of observation. This&amp;nbsp;lead to a problem when merging back with&amp;nbsp;merge_1 file.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293543#M61114</guid>
      <dc:creator>michellel</dc:creator>
      <dc:date>2016-08-23T19:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293550#M61118</link>
      <description>&lt;P&gt;Look into proc surveyselect and a paper called Don't Be Loopy by David Cassell.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recommend a combination approach, using proc surveyselect and the method looping over each file.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293550#M61118</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-23T19:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293554#M61121</link>
      <description>&lt;P&gt;That does look like a significantly different question than the original.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each original data set, why would you want 1,000 separate files?&amp;nbsp; Why wouldn't you create 1 file per original data set, with a variable named SAMPLE that ranges from 1 to 1,000?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 19:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293554#M61121</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-23T19:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293562#M61126</link>
      <description>&lt;P&gt;If when you "merged" the files you had kept some sort of source information you could use the data source as a strata variable in surveyselect. And specify a sample size or rate per strata. The REPS= option would create the specified number of sample replicates of given size per strata.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293562#M61126</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-23T20:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to save more than 1 macro variables together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293565#M61127</link>
      <description>&lt;P&gt;Here's a much simpler approach.&amp;nbsp; It involves little to no macro language, and certainly doesn't require the first macro at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data merged_1_samples;&lt;/P&gt;
&lt;P&gt;do sample=1 to 1000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do recno=1 to _nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get_this_one = ceil(_nobs_ * ranuni(12345));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set merged_1 nobs=_nobs_ point=get_this_one;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can always vary the seed to RANUNI if you would like.&amp;nbsp; But NOBS= retrieves the number of observations in the data set (no macro variable needed) as part of the same DATA step that performs the sampling.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-save-more-than-1-macro-variables-together/m-p/293565#M61127</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-23T20:03:56Z</dc:date>
    </item>
  </channel>
</rss>

