<?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: Scripting and Macro use in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50388#M10513</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
Could you please provide us with more info about the following technical aspects:&lt;BR /&gt;
&lt;BR /&gt;
- Are the files being created based on one or many SAS datasets ?&lt;BR /&gt;
- What kind of files do you need to create ? (CSV, EXCEL, ... etc.)&lt;BR /&gt;
- What are the selection criteria to apply on your data before knowing in which file you'll write the data ?&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Florent</description>
    <pubDate>Thu, 15 Jul 2010 13:03:23 GMT</pubDate>
    <dc:creator>Florent</dc:creator>
    <dc:date>2010-07-15T13:03:23Z</dc:date>
    <item>
      <title>Scripting and Macro use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50387#M10512</link>
      <description>I'm a STATA user trying to start working in SAS, and finding that I cannot figure out how to do some of the programming things I could do easily in Stata.  I'm hoping someone can help.&lt;BR /&gt;
&lt;BR /&gt;
For example, if I write the following code in Stata:&lt;BR /&gt;
&lt;BR /&gt;
forvalues i=1/5 {&lt;BR /&gt;
save d:\myfolder\datafile`i'.dta&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
the value i (called local macro in Stata) would increment from 1 to 5, and the `i' in the filename would be replaced with value characters 1 to 5.  I would save 5 files with slightly different names.&lt;BR /&gt;
&lt;BR /&gt;
Is there equivalent code in SAS?  How do I run code like that outside the confines of a procedure or data step?  In Stata, everything is interactive, so I can script just by typing a series of commands.  In SAS, I cannot just start typing&lt;BR /&gt;
&lt;BR /&gt;
DO i=1 to 5&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Paul</description>
      <pubDate>Thu, 15 Jul 2010 11:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50387#M10512</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-15T11:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting and Macro use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50388#M10513</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
Could you please provide us with more info about the following technical aspects:&lt;BR /&gt;
&lt;BR /&gt;
- Are the files being created based on one or many SAS datasets ?&lt;BR /&gt;
- What kind of files do you need to create ? (CSV, EXCEL, ... etc.)&lt;BR /&gt;
- What are the selection criteria to apply on your data before knowing in which file you'll write the data ?&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Florent</description>
      <pubDate>Thu, 15 Jul 2010 13:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50388#M10513</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2010-07-15T13:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting and Macro use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50389#M10514</link>
      <description>Thanks.  You miss my point a little.  I am asking how to use the macro variable in SAS, and get the program to run.  &lt;BR /&gt;
&lt;BR /&gt;
I am trying to save output from analysis following a simulation of data.  There will be lots of replicates.  &lt;BR /&gt;
&lt;BR /&gt;
However, the question is more general than that.  In Stata, I can just start typing code, and it is very simple.  In SAS, it seems to complain unless code is done within the confines of a Procedure or Data step.  I want to write code that surrounds and manages procedures and data steps, that won't be a part of either, and SAS feels really clunky in that regard.  So again, without going into detail on the data, how would I save 5 different copies of the same data set with slightly different names using a macro to change the target file name?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Paul</description>
      <pubDate>Thu, 15 Jul 2010 13:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50389#M10514</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-15T13:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting and Macro use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50390#M10515</link>
      <description>By using macro code, it can be done that way:&lt;BR /&gt;
&lt;BR /&gt;
%MACRO createFiles(number);           /* MACRO definition */&lt;BR /&gt;
          %DO i= 1 %TO &amp;amp;number;         /* Do loop */&lt;BR /&gt;
                  data _NULL_;                   /* Creation of file */&lt;BR /&gt;
                        file "d:\myfolder\datafile&amp;amp;i..dta";&lt;BR /&gt;
                  run;&lt;BR /&gt;
          %END;&lt;BR /&gt;
%MEND createFiles;&lt;BR /&gt;
&lt;BR /&gt;
%createFiles(5);     /* Number of loops is defined as a parameter of the macro */&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Hope it helps.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Florent</description>
      <pubDate>Thu, 15 Jul 2010 13:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50390#M10515</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2010-07-15T13:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting and Macro use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50391#M10516</link>
      <description>Thanks.  It does help.  It's like Stata, but I have to add those characters % and &amp;amp; in the right places to make it run.&lt;BR /&gt;
&lt;BR /&gt;
P</description>
      <pubDate>Thu, 15 Jul 2010 14:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scripting-and-Macro-use/m-p/50391#M10516</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-15T14:11:48Z</dc:date>
    </item>
  </channel>
</rss>

