<?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 &amp;quot;set&amp;quot; step not resolving inside a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429284#M106021</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169561"&gt;@dewittme&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I killed the comments complete and the macro worked. I did not realise the funky behaviour with the comments with a single *;...The more you know!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks everyone!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It has been quite a few years ago but I know I spent hours going over some simple code that I had made one &lt;U&gt;small&lt;/U&gt; change to that blew up. This was pretty much before most of the internet on line forums existed so there was a lot of trial and error involved. And reading the documentation. Once I had a clue where to look it was there but not the most obvious thing to chase down.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2018 21:17:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-19T21:17:02Z</dc:date>
    <item>
      <title>Data "set" step not resolving inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429175#M105987</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a macro where the first step creates some stats from a t-test, then I do some additional work on the ods output and refer to it by the macro deined "%let" name. I keep getting a "Error 180-322: Statement is not valid or it is used out of proper order" with by step statement in a data step. I'm at a loss.&amp;nbsp; Below is a snippet of the macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro m1 (varlist);&lt;/P&gt;&lt;P&gt;%local i next ;&lt;/P&gt;&lt;P&gt;%let i=1;&lt;/P&gt;&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;varlist));&lt;BR /&gt;%let next=%scan(&amp;amp;varlist,&amp;amp;i);&lt;/P&gt;&lt;P&gt;* Step 1;&lt;BR /&gt;%let lib1 = work;&lt;BR /&gt;%let lib2 = work;&lt;BR /&gt;%let fileorg = survey_of_interest;&lt;BR /&gt;%let pre = &amp;amp;next;&lt;BR /&gt;%let survey = "&amp;amp;next";&lt;/P&gt;&lt;P&gt;DATA survey_of_interest;&lt;BR /&gt;SET data_raw_2;&lt;BR /&gt;WHERE survey_name = &amp;amp;survey;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;ods output "Statistics" = &amp;amp;pre.stats&lt;BR /&gt;"T-Tests" = &amp;amp;pre.ttests&lt;BR /&gt;"Equality of Variances" = &amp;amp;pre.vars;&lt;BR /&gt;proc ttest data=&amp;amp;lib2..&amp;amp;fileorg;&lt;BR /&gt;class finaid;&lt;BR /&gt;*by survey_name;&lt;BR /&gt;var _numeric_;&lt;BR /&gt;run;&lt;BR /&gt;ods output close;&lt;/P&gt;&lt;P&gt;*Step 2;&lt;BR /&gt;*%let lib1 = work;&lt;BR /&gt;*%let pre = finaid_css;&lt;BR /&gt;data &amp;amp;pre.stats1 (keep = survey_name variable class&lt;BR /&gt;mean_nonfinaid mean_finaid pooled_sd);&lt;BR /&gt;&lt;STRONG&gt;set&lt;/STRONG&gt; work.&amp;amp;&amp;amp;pre.stats (rename=(mean=avg));&lt;BR /&gt;%if class = '0'&lt;BR /&gt;%then mean_nonfinaid = avg;&lt;BR /&gt;%if class = '1'&lt;BR /&gt;%then mean_finaid = avg;&lt;/P&gt;&lt;P&gt;%if class = 'Diff (1-2)'&lt;BR /&gt;%then pooled_sd = StdDev;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%mend m1;&lt;/P&gt;&lt;P&gt;%m1(CSS);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I seem to have all the semicolons, but I don't know what is happening.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 16:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429175#M105987</guid>
      <dc:creator>dewittme</dc:creator>
      <dc:date>2018-01-19T16:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data "set" step not resolving inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429179#M105989</link>
      <description>&lt;P&gt;*Step 2;&lt;BR /&gt;*%let lib1 = work;&lt;BR /&gt;*%let pre = finaid_css;&lt;BR /&gt;data &amp;amp;pre.stats1 (keep = survey_name variable class&lt;BR /&gt;mean_nonfinaid mean_finaid pooled_sd);&lt;BR /&gt;set work.&amp;amp;&amp;amp;pre.stats (rename=(mean=avg));&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;%if class = '0'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;%then mean_nonfinaid = avg;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;%if class = '1'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;%then mean_finaid = avg;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;%if class = 'Diff (1-2)'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;%then pooled_sd = StdDev;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;%end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%mend m1;&lt;/P&gt;&lt;P&gt;%m1(CSS);&lt;/P&gt;&lt;P&gt;Assuming Class is a variable in the dataset specified in set statement, I do not get why you are using macro %if %then statements to evaluate datastep variables such as class, shouldn't it be just if then statements?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 16:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429179#M105989</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-19T16:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Data "set" step not resolving inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429180#M105990</link>
      <description>&lt;P&gt;Please look at this from your code:&lt;/P&gt;
&lt;P&gt;data &lt;FONT color="#339966"&gt;&lt;STRONG&gt;&amp;amp;pre&lt;/STRONG&gt;&lt;/FONT&gt;.stats1 (keep = survey_name variable class&lt;BR /&gt;mean_nonfinaid mean_finaid pooled_sd);&lt;BR /&gt;&lt;STRONG&gt;set&lt;/STRONG&gt; work&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;.&amp;amp;&amp;amp;pre.&lt;/STRONG&gt;&lt;/FONT&gt;stats&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last is going to be looking for a macro variable named something that I don't think exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run your code with&lt;/P&gt;
&lt;P&gt;Options Mprint Symbolgen;&lt;/P&gt;
&lt;P&gt;before executing the macro the log will likely give you more information about what you actually created.&lt;/P&gt;
&lt;P&gt;Turn off with&lt;/P&gt;
&lt;P&gt;Options Nomprint Nosymbolgen;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you used some comments here:&lt;/P&gt;
&lt;PRE&gt;ods output close;

*Step 2;
*%let lib1 = work;
*%let pre = finaid_css;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which may cause unexpected results.&lt;/P&gt;
&lt;P&gt;Inside a macro block you want comments to be either&lt;/P&gt;
&lt;P&gt;/* %let lib1=work; */&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;%* %let lib1 = work;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a number of reasons I always use the /*&amp;nbsp; */ comment. One reason: editor support for comment /uncomment with Ctrl-/ and Shift-Ctrl-/&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 16:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429180#M105990</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-19T16:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Data "set" step not resolving inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429256#M106014</link>
      <description>&lt;P&gt;I killed the comments complete and the macro worked. I did not realise the funky behaviour with the comments with a single *;...The more you know!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 19:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429256#M106014</guid>
      <dc:creator>dewittme</dc:creator>
      <dc:date>2018-01-19T19:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Data "set" step not resolving inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429284#M106021</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169561"&gt;@dewittme&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I killed the comments complete and the macro worked. I did not realise the funky behaviour with the comments with a single *;...The more you know!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks everyone!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It has been quite a few years ago but I know I spent hours going over some simple code that I had made one &lt;U&gt;small&lt;/U&gt; change to that blew up. This was pretty much before most of the internet on line forums existed so there was a lot of trial and error involved. And reading the documentation. Once I had a clue where to look it was there but not the most obvious thing to chase down.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 21:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-quot-set-quot-step-not-resolving-inside-a-macro/m-p/429284#M106021</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-19T21:17:02Z</dc:date>
    </item>
  </channel>
</rss>

