<?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 these maro variable? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526420#M5082</link>
    <description>&lt;P&gt;I want to derive suffix from my_date for later use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this code but it did not work&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;%let my_date = 20180112; /* YYYYMMDD */

data suff;

format ref_date date9.;

ref_date = mdy(substr(put(&amp;amp;my_date,$8.),5,2), substr(put(&amp;amp;scoring_date,$8.),7,2), substr(put(&amp;amp;scoring_date,$8.),1,4));

suffix=catx('_','put(intnx('month',ref_date,-16),yymm.));',put(intnx('month',ref_date,-1),yymm.));

 

run;

 

proc sql;

select suffix into :suffix 

from suff;

quit.



&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;it doest work.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Jeff&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jan 2019 17:02:04 GMT</pubDate>
    <dc:creator>JP1234</dc:creator>
    <dc:date>2019-01-11T17:02:04Z</dc:date>
    <item>
      <title>How to create these maro variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526412#M5079</link>
      <description>&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;I have a date&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mydate = 20180112; /*yyyymmdd */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I&amp;nbsp;want&amp;nbsp;to create macro vaiable suffix = 201709_201811; /*(yyyymm-yyyymm)*/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;How can i do that?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Jeff&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 16:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526412#M5079</guid>
      <dc:creator>JP1234</dc:creator>
      <dc:date>2019-01-11T16:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create these maro variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526417#M5080</link>
      <description>&lt;P&gt;I'm probably not understanding the problem, but ... based on what you said, you create the suffix macro variable as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let suffix = 201709_201811;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jan 2019 16:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526417#M5080</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-11T16:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create these maro variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526420#M5082</link>
      <description>&lt;P&gt;I want to derive suffix from my_date for later use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this code but it did not work&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;%let my_date = 20180112; /* YYYYMMDD */

data suff;

format ref_date date9.;

ref_date = mdy(substr(put(&amp;amp;my_date,$8.),5,2), substr(put(&amp;amp;scoring_date,$8.),7,2), substr(put(&amp;amp;scoring_date,$8.),1,4));

suffix=catx('_','put(intnx('month',ref_date,-16),yymm.));',put(intnx('month',ref_date,-1),yymm.));

 

run;

 

proc sql;

select suffix into :suffix 

from suff;

quit.



&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;it doest work.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Jeff&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 17:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526420#M5082</guid>
      <dc:creator>JP1234</dc:creator>
      <dc:date>2019-01-11T17:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create these maro variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526424#M5084</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; Saying it just doesn't work is rather vague. Are you getting ERROR messages or WARNING messages in the SAS log? If so, have you tried to determine why you're getting those messages? &lt;BR /&gt;&lt;BR /&gt;What is the purpose of the SQL step? If you need a macro variable why not create it with CALL SYMPUT in the DATA step program where you are creating SUFFIX?? You don't need a separate SQL step.&lt;BR /&gt;&lt;BR /&gt;What is the disposition of &amp;amp;SUFFIX or, how do you plan to use it? Why is &amp;amp;MY_DATE a macro variable? What is the value for &amp;amp;SCORING_DATE? No one can run your code because you only provide a value for &amp;amp;MY_DATE.&lt;BR /&gt;&lt;BR /&gt; Since no one can run your code without values for &amp;amp;SCORING_DATE and since you have an error in the SQL code (period after quit), It is hard to figure out what you need or why you've used this approach.&lt;BR /&gt;&lt;BR /&gt; Can you clarify?&lt;BR /&gt;Thanks,&lt;BR /&gt;Cynthia&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 17:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526424#M5084</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-01-11T17:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create these maro variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526426#M5085</link>
      <description>&lt;P&gt;Why not use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ref_date= input("&amp;amp;my_date.",yymmdd8);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of futzing around with string functions AND not ever turning the strings into the numeric values that MDY requires. Which is what is generating multiple errors in your existing code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or changing the value of your my_date variable and using that directly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let mydate=12JAN2018;&lt;/P&gt;
&lt;P&gt;suffix=catx('_','put(intnx('month', "&amp;amp;my_date."d ,-16),yymm.));',put(intnx('month', "&amp;amp;my_date."d ,-1),yymm.));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 17:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-these-maro-variable/m-p/526426#M5085</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-11T17:33:49Z</dc:date>
    </item>
  </channel>
</rss>

