<?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: keep macro variable in dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473929#M121683</link>
    <description>&lt;P&gt;That's strange.&amp;nbsp; But can&amp;nbsp; you please run a proc contents to check whether or not there is a variable by the name&amp;nbsp;&lt;SPAN&gt;HEATERSUB in your dataset&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;rawdata_transp&lt;/STRONG&gt;&lt;/EM&gt;?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jun 2018 22:29:25 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-06-27T22:29:25Z</dc:date>
    <item>
      <title>keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473919#M121676</link>
      <description>&lt;P&gt;I met problem using macro variable in my SAS code.&lt;/P&gt;&lt;P&gt;I need to define a macro variable and keep the column in dataset operation.&lt;/P&gt;&lt;P&gt;%let target_parm = temperature; // so I can change temperature into other parameter later if necessary&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;//pull data and form a dataset called rawdata which includes a column called temerature&lt;/P&gt;&lt;P&gt;data output (keep = day month year &amp;amp;target_parm.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;set rawdata;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will return error variable name is not valid.&lt;/P&gt;&lt;P&gt;I saw examples online of referring macro variable usually is &amp;amp;target_parm without ".", but I need to use the form with "." otherwise in some other parts this macro variable will not work (like the operation of pulling temperature data).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone explain to me the difference of w/o "." in &amp;amp;target_parm? And how should I modify the code so the macro variable can be used in keep function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 22:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473919#M121676</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-27T22:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473921#M121677</link>
      <description>&lt;P&gt;You wrote -"&amp;nbsp;&lt;SPAN&gt;This will return error variable name is not valid"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Why you say that?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It seems to work fine in the below example&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let target_parm = height;&lt;/P&gt;&lt;P&gt;data output (keep = name &amp;amp;target_parm.);&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 22:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473921#M121677</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-27T22:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473922#M121678</link>
      <description>It is not working on my side.&lt;BR /&gt;ERROR: variable name &amp;amp; is not valid.&lt;BR /&gt;ERROR: Invalid for the KEEP option.</description>
      <pubDate>Wed, 27 Jun 2018 22:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473922#M121678</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-27T22:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473925#M121680</link>
      <description>&lt;P&gt;Please post your code and log&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 22:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473925#M121680</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-27T22:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473928#M121682</link>
      <description>&lt;P&gt;/************************ define variable *****************************/&lt;BR /&gt;%let target_wafer = 288760;&lt;BR /&gt;%let target_op = 9689;&lt;BR /&gt;%let target_parm = 'HEATERSUB';&lt;BR /&gt;%let PARM = HEATERSUB;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/************************ pull raw data from CHIMP *****************************/&lt;BR /&gt;proc sql;&lt;BR /&gt;connect to db2 (&amp;amp;wafer_server.);&lt;BR /&gt;create table rawdata&lt;BR /&gt;as select * from connection to db2 (&lt;/P&gt;&lt;P&gt;SELECT A.WAFERNUM, A.PROCESSDATE, A.HT, A.OP, A.WAFERSIZE, A.PARMNAME, A.ROWNUM, A.COL01,A.COL02,A.COL03,A.COL04,A.COL05,A.COL06,A.COL07,A.COL08,&lt;BR /&gt;A.COL09,A.COL10,A.COL11,A.COL12,A.COL13,A.COL14,A.COL15,A.COL16,A.COL17,A.COL18,A.COL19,A.COL20,A.COL21,A.COL22,&lt;BR /&gt;A.COL23,A.COL24,A.COL25,A.COL26,A.COL27,A.COL28,A.COL29,A.COL30,A.COL31,A.COL32,A.COL33,A.COL34,A.COL35,A.COL36,&lt;BR /&gt;A.COL37,A.COL38,A.COL39,A.COL40,A.COL41,A.COL42,A.COL43,A.COL44,A.COL45,A.COL46,A.COL47,A.COL48,A.COL49,A.COL50,&lt;BR /&gt;A.COL51,A.COL52,A.COL53,A.COL54,A.COL55,A.COL56,A.COL57,A.COL58,A.COL59,A.COL60&lt;BR /&gt;From wtooldet.CHIMP A&lt;BR /&gt;WHERE A.WAFERNUM in (&amp;amp;target_wafer.)&lt;BR /&gt;AND A.PARMNAME in (&amp;amp;target_parm.)&lt;BR /&gt;AND A.OP in (&amp;amp;target_op.)&lt;/P&gt;&lt;P&gt;order by ROWNUM&lt;BR /&gt;&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;disconnect from db2;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc transpose data=rawdata&lt;BR /&gt;out=rawdata_transp&lt;BR /&gt;name=COLNUM;&lt;BR /&gt;label COLNUM='COLNUM';&lt;BR /&gt;by WAFERNUM WAFERSIZE ROWNUM PROCESSDATE;&lt;BR /&gt;var COL01 - COL60;&lt;BR /&gt;id PARMNAME;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data rawdata_transp (keep = WAFERNUM WAFERSIZE ROWNUM COLNUM &amp;amp;PARM.);&lt;BR /&gt;set rawdata_transp;&lt;BR /&gt;colnum = substr(COLNUM,4,2);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;1303 data rawdata_transp (keep = WAFERNUM WAFERSIZE ROWNUM COLNUM &amp;amp;PARM.);&lt;BR /&gt;-&lt;BR /&gt;214&lt;BR /&gt;23&lt;BR /&gt;ERROR 214-322: Variable name &amp;amp; is not valid.&lt;/P&gt;&lt;P&gt;ERROR 23-7: Invalid value for the KEEP option.&lt;/P&gt;&lt;P&gt;-----&lt;BR /&gt;23&lt;BR /&gt;1303! data rawdata_transp (keep = WAFERNUM WAFERSIZE ROWNUM COLNUM &amp;amp;PARM.);&lt;BR /&gt;-----&lt;BR /&gt;214&lt;BR /&gt;WARNING: Apparent symbolic reference PARM not resolved.&lt;BR /&gt;ERROR 214-322: Variable name PARM. is not valid.&lt;/P&gt;&lt;P&gt;1304 set rawdata_transp;&lt;BR /&gt;1305 colnum = substr(COLNUM,4,2);&lt;BR /&gt;1306 run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I defined two macro variable to define HEATERSUB w/o '', because the '&amp;amp;PARM.' is not working.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 22:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473928#M121682</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-27T22:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473929#M121683</link>
      <description>&lt;P&gt;That's strange.&amp;nbsp; But can&amp;nbsp; you please run a proc contents to check whether or not there is a variable by the name&amp;nbsp;&lt;SPAN&gt;HEATERSUB in your dataset&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;rawdata_transp&lt;/STRONG&gt;&lt;/EM&gt;?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 22:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473929#M121683</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-27T22:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473930#M121684</link>
      <description>Yes there is</description>
      <pubDate>Wed, 27 Jun 2018 22:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473930#M121684</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-27T22:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473983#M121713</link>
      <description>&lt;P&gt;This is the crucial message:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: Apparent symbolic reference PARM not resolved.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So it seems that your&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let PARM = HEATERSUB;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;somehow does not work. I have an inkling you are not showing us all your code.&lt;/P&gt;
&lt;P&gt;Add&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put _global_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;at appropriate locations in your code to reveal the status of your global macro symbol table.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 07:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473983#M121713</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-28T07:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473985#M121714</link>
      <description>&lt;P&gt;PS your basic idea for the algorithm is sound, see this simple example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class (keep=name sex);
value = 1;
run;

%let parm=F;

proc transpose data=class out=class1;
by name;
var value;
id sex;
run;

data want;
set class1 (keep=name &amp;amp;parm.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so it must be something that either prevents the setting of &amp;amp;PARM in the necessary context (eg local vs. global symbol table), or you have some code that clears &amp;amp;parm from the symbol table.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 07:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/473985#M121714</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-28T07:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/474142#M121778</link>
      <description>thx, I've figure it out, there was something else wrong</description>
      <pubDate>Thu, 28 Jun 2018 16:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/474142#M121778</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-28T16:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/474150#M121781</link>
      <description>&lt;P&gt;It would be nice if you could tell us what exactly happened, as it might help others that are brought to this thread by the search function.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 16:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/474150#M121781</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-28T16:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: keep macro variable in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/474153#M121782</link>
      <description>The reason is part of my code works in server environment and part is in desktop environment. The macro variable defined on server is not recognized by my local machine.</description>
      <pubDate>Thu, 28 Jun 2018 16:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-macro-variable-in-dataset/m-p/474153#M121782</guid>
      <dc:creator>leonzheng</dc:creator>
      <dc:date>2018-06-28T16:26:34Z</dc:date>
    </item>
  </channel>
</rss>

