<?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: data and Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350639#M81522</link>
    <description>&lt;P&gt;Thanks Artc&lt;/P&gt;</description>
    <pubDate>Mon, 17 Apr 2017 20:43:59 GMT</pubDate>
    <dc:creator>Melvin_Sas</dc:creator>
    <dc:date>2017-04-17T20:43:59Z</dc:date>
    <item>
      <title>data and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350600#M81503</link>
      <description>&lt;P&gt;I need to assign values to global macro variable based on a if condition , But it fails with error&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%global&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Status;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Hello;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Infile&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'C:\Users\FSAX.txt'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;truncover&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a_line &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$2000.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(a_line, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'ERROR:'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Main = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;If&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Main&amp;nbsp;= 1 &lt;/FONT&gt;&amp;nbsp;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Status = 'Failed : ';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;This macro varibale Status&amp;nbsp;is used in other macro functions.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 18:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350600#M81503</guid>
      <dc:creator>Melvin_Sas</dc:creator>
      <dc:date>2017-04-17T18:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: data and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350605#M81506</link>
      <description>&lt;P&gt;Macro language elements (like the %LET statement) cannot be conditionally executed by DATA step IF-THEN/ELSE.&amp;nbsp; Instead use the DATA step's SYMPUTX routine to make the assignment.&amp;nbsp; The IF statement becomes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If Main = 1  then call symputx('status','Failed','g');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Apr 2017 18:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350605#M81506</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2017-04-17T18:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: data and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350608#M81508</link>
      <description>&lt;P&gt;Expanding on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13683"&gt;@ArtC&lt;/a&gt;'s comment, I'd also include a check so that only one attempt is needed to create the macro variable. e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Hello;
  Infile 'C:\Users\FSAX.txt' truncover;
  input a_line $2000. ;
 
  if index(a_line, 'ERROR:') &amp;gt; 0 then Main = 1;
 
  If eof and Main = 1  then call symputx('Status','Failed : ','g');
run;

%put &amp;amp;Status.;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 19:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350608#M81508</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-17T19:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: data and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350622#M81515</link>
      <description>&lt;P&gt;Thanks Atrc.. I tried the below code but the value is always success,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Checkerror Dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;a_line&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Error&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;This is a dealership account ERROR: expires only by Dec'2016.&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%global&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Status;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; CheckError;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Infile&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'C:\Users\FSAX.txt'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;truncover&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a_line &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$2000.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(a_line, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'ERROR:'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Error = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;If&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Error = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;RUN&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; CheckError;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;If&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Error = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Status'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Failed : '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'g'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Else&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Status'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Success : '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'g'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;Status.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 19:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350622#M81515</guid>
      <dc:creator>Melvin_Sas</dc:creator>
      <dc:date>2017-04-17T19:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: data and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350627#M81516</link>
      <description>Include a SET statement in your second step.  You are not reading any data, the variable ERROR is always missing.  Move the %PUT until after the RUN;.  A macro %PUT cannot be conditionally executed within the DATA step.</description>
      <pubDate>Mon, 17 Apr 2017 19:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350627#M81516</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2017-04-17T19:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: data and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350629#M81518</link>
      <description>&lt;P&gt;Combining a number of suggestions (and adding 1 or 2 more):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;Infile&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#800080"&gt;'C:\Users\FSAX.txt'&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;truncover&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a_line &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;$2000.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(a_line, &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'ERROR:'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp; &amp;nbsp;call symput('Status', 'Failed : ');&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp; &amp;nbsp;stop;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;You don't really need to create a SAS data set (hence _NULL_), and you don't need to continue the DATA step once a single "ERROR:" is found (hence STOP).&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 19:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350629#M81518</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-17T19:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: data and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350639#M81522</link>
      <description>&lt;P&gt;Thanks Artc&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 20:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-and-Macro/m-p/350639#M81522</guid>
      <dc:creator>Melvin_Sas</dc:creator>
      <dc:date>2017-04-17T20:43:59Z</dc:date>
    </item>
  </channel>
</rss>

