<?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 create macro variable and use it in one data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666296#M199329</link>
    <description>&lt;P&gt;Your double quotes are curly quotes and not typed from the keyboard. Use straight quotes. Type them yourself in the SAS editor.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jul 2020 07:54:09 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-07-01T07:54:09Z</dc:date>
    <item>
      <title>How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666273#M199321</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;How to modify the code to run successfully?&lt;/P&gt;
&lt;P&gt;I want to use &amp;amp;faa in one data set.&lt;/P&gt;
&lt;P&gt;%scan(symget('faa'),&amp;amp;i,|) can't run successfully too.&lt;/P&gt;
&lt;PRE&gt;%macro ff;
data a;
  if _n_=1 then do; 
     aa='f|dd|ff';
     call symputx('faa',aa);
  end;
  set xx;
  %let i=1;
  %do %until (%scan(&amp;amp;faa,&amp;amp;i,|) = );
     %scan(&amp;amp;f,&amp;amp;i,|)='1';
     %let i=%eval(&amp;amp;i+1);
  %end;
run;

%mend;
%ff;&lt;/PRE&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 06:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666273#M199321</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2020-07-01T06:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666275#M199322</link>
      <description>&lt;P&gt;Anything macro executes before the SAS data step and that's why you've got a timing issue here. The macro %do loop executes before the SAS data step creates macro variable&amp;nbsp;&amp;amp;faa.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain what you're actually trying to do. There is a good chance that you don't need macro code at all.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 06:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666275#M199322</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-01T06:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666277#M199324</link>
      <description>&lt;P&gt;What do you want to achieve? It seems as if you want to to set the variable "f", "dd" and "ff to 1. All&amp;nbsp; variables seem to be alphanumeric, right? If yes, you don't need macro-code, but an array:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
   set xx;

   array vars[3] f dd ff;

   do i = 1 to dim(vars);
      vars[i] = '1';
   end;

   drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Jul 2020 06:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666277#M199324</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-07-01T06:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666278#M199325</link>
      <description>&lt;P&gt;You have a basic macro timing problem. CALL SYMPUTX works at data step execution time, but the macro code is resolved while the macro creates the code that will later be compiled into a data step, so it will try to fetch the macro variable long before it is created.&lt;/P&gt;
&lt;P&gt;The deeper issue here is that you try to abuse the macro language for something it is not meant to do: manipulate &lt;EM&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To keep values across observations, use a RETAINed variable, or set a macro variable before the data step. To present valid code, we first need to know the data you start with, and what you want to get out of it.&lt;/P&gt;
&lt;P&gt;Please supply an example dataset in a data step with datalines, and the expected result from it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 06:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666278#M199325</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-01T06:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666284#M199326</link>
      <description>&lt;P&gt;Timing issue as you were told.&lt;/P&gt;
&lt;P&gt;When the data step compiles, all variables must be known.&lt;/P&gt;
&lt;P&gt;So:&lt;/P&gt;
&lt;PRE&gt;%scan(&amp;amp;faa,&amp;amp;i,|)&lt;/PRE&gt;
&lt;P&gt;must be resolved.&lt;/P&gt;
&lt;P&gt;This is of course impossible in your scenario as &amp;amp;f is unknown at compile time.&lt;/P&gt;
&lt;P&gt;Also note the inconsistency: you seem to have confused variables &amp;amp;f and &amp;amp;faa .&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 07:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666284#M199326</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-01T07:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666294#M199328</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;I put the step of creating macro variable before this data set.&lt;/P&gt;
&lt;P&gt;But I have a new question.&lt;/P&gt;
&lt;P&gt;why I use double quotation marks in hash then the log&amp;nbsp;generates issue?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lee_wan_2-1593589764834.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46820iDF3C8CD648EBD3BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lee_wan_2-1593589764834.png" alt="Lee_wan_2-1593589764834.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I replace them with single quotes('cmseq'), there's no problem.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 07:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666294#M199328</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2020-07-01T07:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666296#M199329</link>
      <description>&lt;P&gt;Your double quotes are curly quotes and not typed from the keyboard. Use straight quotes. Type them yourself in the SAS editor.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 07:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666296#M199329</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-01T07:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable and use it in one data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666298#M199331</link>
      <description>&lt;PRE&gt;data cm;
    if _N_=1 then do;
        dcl hash h(multidata:'Y');
        h.definekey('usubjid', "cmseq");
        h.definedata('qnam', 'qval');
        h.definedone();

        do until(eof);
          set sdtm.suppcm end=eof;
          cmseq=input(idvarval,best.);
          rc=h.add();
        end;
    end;&lt;/PRE&gt;
&lt;P&gt;It's not about double quotes.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 08:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-and-use-it-in-one-data-set/m-p/666298#M199331</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2020-07-01T08:09:57Z</dc:date>
    </item>
  </channel>
</rss>

