<?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: Macro Variable Help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Help/m-p/246698#M46190</link>
    <description>&lt;P&gt;perfect -thank you &amp;nbsp;-I guess I was overthinking it...&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jan 2016 17:06:39 GMT</pubDate>
    <dc:creator>TMiles</dc:creator>
    <dc:date>2016-01-28T17:06:39Z</dc:date>
    <item>
      <title>Macro Variable Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Help/m-p/246689#M46185</link>
      <description>&lt;P&gt;I have been away from SAS for about 5 years and for the life of me I cannot figure out why even though the marcrovar appears to resolve correctly, it is not working. &amp;nbsp;Below are examples if I use the macrovar - error, if I explicitly type '2016' i get results. &amp;nbsp;I am sure I have just forgotton something very basic, but I am really stumped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1544 options ls=250 nocenter macrogen symbolgen source;&lt;BR /&gt;1545&lt;BR /&gt;1546 %let d1=%eval(%sysfunc(today()));&lt;BR /&gt;1547 %let d1a=%sysfunc(putn(&amp;amp;d1,mmddyy10.));&lt;BR /&gt;SYMBOLGEN: Macro variable D1 resolves to 20481&lt;BR /&gt;1548 %let enddate = %eval(%sysfunc(intnx(week,&amp;amp;d1,0))+6);&lt;BR /&gt;SYMBOLGEN: Macro variable D1 resolves to 20481&lt;BR /&gt;1549 %let enddatea=%sysfunc(putn(&amp;amp;enddate,mmddyy10.));&lt;BR /&gt;SYMBOLGEN: Macro variable ENDDATE resolves to 20483&lt;BR /&gt;1550 %let begdate = %eval(&amp;amp;enddate-364);&lt;BR /&gt;SYMBOLGEN: Macro variable ENDDATE resolves to 20483&lt;BR /&gt;1551 %let begdatea=%sysfunc(putn(&amp;amp;begdate,mmddyy10.));%put &amp;amp;begdatea;&lt;BR /&gt;SYMBOLGEN: Macro variable BEGDATE resolves to 20119&lt;BR /&gt;SYMBOLGEN: Macro variable BEGDATEA resolves to 01/31/2015&lt;BR /&gt;01/31/2015&lt;BR /&gt;1552 %let year1=%eval(%sysfunc(intnx(year,&amp;amp;d1,-1)));&lt;BR /&gt;SYMBOLGEN: Macro variable D1 resolves to 20481&lt;BR /&gt;1553 %let year2=%eval(%sysfunc(intnx(year,&amp;amp;d1,0)));&lt;BR /&gt;SYMBOLGEN: Macro variable D1 resolves to 20481&lt;BR /&gt;1554 %let firstyear=%str(%')%sysfunc(putn(&amp;amp;year1,year4.))%str(%');%put &amp;amp;firstyear=;&lt;BR /&gt;SYMBOLGEN: Macro variable YEAR1 resolves to 20089&lt;BR /&gt;SYMBOLGEN: Macro variable FIRSTYEAR resolves to '2015'&lt;BR /&gt;SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;BR /&gt;'2015'=&lt;BR /&gt;1555 %let curryear=%str(%')%sysfunc(putn(&amp;amp;year2,year4.))%str(%');%put &amp;amp;curryear=;&lt;BR /&gt;SYMBOLGEN: Macro variable YEAR2 resolves to 20454&lt;BR /&gt;SYMBOLGEN: Macro variable CURRYEAR resolves to '2016'&lt;BR /&gt;SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;BR /&gt;'2016'=&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data itemdata(drop=ohdr_demand ohdr_qty ohdr_lines ohdr_margin)&lt;BR /&gt;1511 orddata(drop=item_status_at_order demandafterdisc demandcost demandmargin demandqty swki findings chains seedbeads gwp);&lt;BR /&gt;1512 set out1.itemdata;&lt;BR /&gt;1513 *if sales_year = '2016';&lt;BR /&gt;1514 if sales_year = &amp;amp;curryear;&lt;BR /&gt;SYMBOLGEN: Macro variable CURRYEAR resolves to '2016'&lt;BR /&gt;SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;BR /&gt;NOTE: Line generated by the macro variable "CURRYEAR".&lt;BR /&gt;1 '2016'&lt;BR /&gt;-&lt;BR /&gt;390&lt;BR /&gt;-&lt;BR /&gt;200&lt;BR /&gt;ERROR 390-185: Expecting an relational or arithmetic operator.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;1515 if substr(curr_cat,2,1) = 'K' and substr(curr_cat,4,1) = 'A' and put(shipped_item,$swrgwp.) = 'NOT SWRGWP' then swki = 1;else swki = 0;&lt;BR /&gt;1516 if substr(curr_cat,1,1) = 'M' then findings = 1;else findings = 0;&lt;BR /&gt;1517 if substr(curr_cat,1,1) = 'H' then chains = 1;else chains = 0;&lt;BR /&gt;1518 if substr(curr_cat,1,1) = 'E' then seedbeads = 1;else seedbeads = 0;&lt;BR /&gt;1519 if put(shipped_item,$gwpmat.) not in ('NOT GWP') then gwp = 1;else gwp = 0;&lt;BR /&gt;1520 cust_type = current_cust_type_at_eom;&lt;BR /&gt;1521 if cust_type = ' ' then cust_type = current_cust_type;&lt;BR /&gt;1522 if cust_type = ' ' then cust_type = cust_type_at_eom;&lt;BR /&gt;1523 if cust_type = ' ' then cust_type = cust_type_at_time_of_order;&lt;BR /&gt;1524 weekend=intnx('week',datepart(ord_mail_dt),0)+6;&lt;BR /&gt;1525 format weekend mmddyy10.;&lt;BR /&gt;1526 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.ITEMDATA may be incomplete. When this step was stopped there were 0 observations and 26 variables.&lt;BR /&gt;WARNING: Data set WORK.ITEMDATA was not replaced because this step was stopped.&lt;BR /&gt;WARNING: The data set WORK.ORDDATA may be incomplete. When this step was stopped there were 0 observations and 20 variables.&lt;BR /&gt;WARNING: Data set WORK.ORDDATA was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.05 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1527 data itemdata(drop=ohdr_demand ohdr_qty ohdr_lines ohdr_margin)&lt;BR /&gt;1528 orddata(drop=item_status_at_order demandafterdisc demandcost demandmargin demandqty swki findings chains seedbeads gwp);&lt;BR /&gt;1529 set out1.itemdata;&lt;BR /&gt;1530 if sales_year = '2016';&lt;BR /&gt;1531 *if sales_year = &amp;amp;curryear;&lt;BR /&gt;1532 if substr(curr_cat,2,1) = 'K' and substr(curr_cat,4,1) = 'A' and put(shipped_item,$swrgwp.) = 'NOT SWRGWP' then swki = 1;else swki = 0;&lt;BR /&gt;1533 if substr(curr_cat,1,1) = 'M' then findings = 1;else findings = 0;&lt;BR /&gt;1534 if substr(curr_cat,1,1) = 'H' then chains = 1;else chains = 0;&lt;BR /&gt;1535 if substr(curr_cat,1,1) = 'E' then seedbeads = 1;else seedbeads = 0;&lt;BR /&gt;1536 if put(shipped_item,$gwpmat.) not in ('NOT GWP') then gwp = 1;else gwp = 0;&lt;BR /&gt;1537 cust_type = current_cust_type_at_eom;&lt;BR /&gt;1538 if cust_type = ' ' then cust_type = current_cust_type;&lt;BR /&gt;1539 if cust_type = ' ' then cust_type = cust_type_at_eom;&lt;BR /&gt;1540 if cust_type = ' ' then cust_type = cust_type_at_time_of_order;&lt;BR /&gt;1541 weekend=intnx('week',datepart(ord_mail_dt),0)+6;&lt;BR /&gt;1542 format weekend mmddyy10.;&lt;BR /&gt;1543 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 11415407 observations read from the data set OUT1.ITEMDATA.&lt;BR /&gt;NOTE: The data set WORK.ITEMDATA has 575080 observations and 26 variables.&lt;BR /&gt;NOTE: The data set WORK.ORDDATA has 575080 observations and 20 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 6.87 seconds&lt;BR /&gt;cpu time 6.48 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 16:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Help/m-p/246689#M46185</guid>
      <dc:creator>TMiles</dc:creator>
      <dc:date>2016-01-28T16:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Help/m-p/246690#M46186</link>
      <description>&lt;P&gt;Don't include quotes in your macro variable, add them in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cur_year=2016;

...
if year = "&amp;amp;cur_year";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jan 2016 16:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Help/m-p/246690#M46186</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-28T16:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Help/m-p/246698#M46190</link>
      <description>&lt;P&gt;perfect -thank you &amp;nbsp;-I guess I was overthinking it...&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 17:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Help/m-p/246698#M46190</guid>
      <dc:creator>TMiles</dc:creator>
      <dc:date>2016-01-28T17:06:39Z</dc:date>
    </item>
  </channel>
</rss>

