<?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 I do fix the below mentioned SAS Macro Code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446571#M112058</link>
    <description>&lt;P&gt;You can either fix the %VISIT() macro by adding an %UNQUOTE() call around the dataset name that is getting broken up because of the macro quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can fix your looping/driver program to NOT add the macro quoting to begin with.&lt;/P&gt;
&lt;P&gt;Change.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET YR =%qsubstr(&amp;amp;date,6,4);
%LET MON =%qsubstr(&amp;amp;date, 3,3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET YR =%substr(&amp;amp;date,6,4);
%LET MON =%substr(&amp;amp;date, 3,3);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 18 Mar 2018 14:05:44 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-03-18T14:05:44Z</dc:date>
    <item>
      <title>How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446454#M112013</link>
      <description>&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;01JAN2015&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the macro variable "YR".&lt;/P&gt;&lt;P&gt;44 visit_in_JAN2015&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;____&lt;/P&gt;&lt;P&gt;200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;/*CODE*/&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; startdate= '01Jan2015'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &lt;STRONG&gt;&lt;I&gt;loop&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;24&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; prev_month=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(intnx(month,"&amp;amp;startdate"d,-1), date9.);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; date=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(intnx(month,"&amp;amp;prev_month"d, &amp;amp;i.), date9.);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &amp;amp;date.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; month= &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(month("&amp;amp;date"d));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; yr= &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(year("&amp;amp;date"d));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; mon=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%qsubstr&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(&amp;amp;date, 3,3);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;%&lt;STRONG&gt;&lt;I&gt;visit&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New"&gt;mon.&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New"&gt;yr.&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &amp;amp;month &amp;amp;yr &amp;amp;mon;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;loop&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; startdate= '01Jan2015'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &lt;STRONG&gt;&lt;I&gt;loop&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;24&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; prev_month=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(intnx(month,"&amp;amp;startdate"d,-1), date9.);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; date=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(intnx(month,"&amp;amp;prev_month"d, &amp;amp;i.), date9.);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &amp;amp;date.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; month= &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(month("&amp;amp;date"d));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; yr= &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(year("&amp;amp;date"d));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; mon=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%qsubstr&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(&amp;amp;date, 3,3);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;%&lt;STRONG&gt;&lt;I&gt;visit&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New"&gt;mon.&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New"&gt;yr.&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; &amp;amp;month &amp;amp;yr &amp;amp;mon;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;loop&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 15:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446454#M112013</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-17T15:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446471#M112018</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You have 2 macro programs at work. It is pretty clear that the %loop macro is just creating values that are being passed to the %visit macro. I removed the call to %visit and tested only your other statements in %loop and it appears that they are working correctly. As you can see from running the program a limited number of times, a valid value for YR seems to be generated:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="prob_not_inside_loop_macro.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19258i769D9DA439F37B6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="prob_not_inside_loop_macro.png" alt="prob_not_inside_loop_macro.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Your error message was fairly clear, though, that something that is generated when &amp;amp;YR is used &lt;STRONG&gt;&lt;U&gt;inside&lt;/U&gt; &lt;/STRONG&gt;%visit is causing the error message. Have you turned on MLOGIC, SYMBOLGEN and MPRINT? What is the %visit macro program doing? My suggestion is that you review what is in %visit outside of the %loop macro program and see why the error is generated inside %visit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 18:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446471#M112018</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-03-17T18:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446473#M112019</link>
      <description>&lt;P&gt;It would help if you post your %visit macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 18:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446473#M112019</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-03-17T18:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446494#M112027</link>
      <description>&lt;P&gt;Use a DATA step and CALL execute to loop your macros rather than another macro loop. It's much easier to work with and debug.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 22:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446494#M112027</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-17T22:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446521#M112034</link>
      <description>&lt;P&gt;Just a shot in the dark since you have not posted the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you adding macro quoting to a three character string that does not contain any special characters?&lt;BR /&gt;Try changing to regular substr().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mon=%substr(&amp;amp;date, 3,3);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Mar 2018 02:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446521#M112034</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-18T02:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446524#M112037</link>
      <description>&lt;P&gt;The visit&amp;nbsp; macro is creating output SAS datasets for each month and respective year. So that&amp;nbsp;we need to add manually for each year and month. instead of that if I can create a macros in do loop&amp;nbsp;and passing parameters for start date and end date so that it will execute.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;finally that output format it should be (visit_in_jan2016 and so on...). &amp;nbsp;&lt;/STRONG&gt;that is why I added this statement.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; mon&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token macroname"&gt;%substr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To avoid the below steps I created macro. Like that for each year and each month..&lt;/P&gt;&lt;P&gt;%visit(jan,2016);&lt;BR /&gt;%visit(feb,2016);&lt;BR /&gt;%visit(mar,2016);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please find the below visit macro&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro visit(mon,yr);&lt;BR /&gt;data out.visit_in_&amp;amp;mon.&amp;amp;yr.;&lt;BR /&gt;&amp;nbsp; length diag_i_1-diag_i_50 $10.;&lt;BR /&gt;&amp;nbsp; set visit_in_&amp;amp;mon.&amp;amp;yr.;* (obs=100 );&lt;BR /&gt;&amp;nbsp; prov_nbr=COMPRESS(UPCASE(LEFT(TRIM(PROV_NBR))),'-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ','k');&lt;/P&gt;&lt;P&gt;&amp;nbsp; array diag_i_ {50}&amp;nbsp; diag_i_1-diag_i_50;&lt;BR /&gt;&amp;nbsp; array proc_i_ {24}&amp;nbsp; proc_i_1-proc_i_24;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to 50;&lt;BR /&gt;&amp;nbsp; diag_i_{i}=compress(diag_i_{i},".");&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if icd_flag=9 then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if diag_i_{i} ne '' and substr(diag_i_{i},1,1) = 'E' and length(diag_i_{i}) &amp;gt; 4 then diag_i_{i} = substr(diag_i_{i},1,4)||"."||substr(diag_i_{i},5,1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if diag_i_{i} ne '' and substr(diag_i_{i},1,1) = 'E' and length(diag_i_{i}) &amp;lt;=4 then diag_i_{i}=diag_i_{i};&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if diag_i_{i} ne '' and length(diag_i_{i}) &amp;gt; 3 then diag_i_{i}=substr(diag_i_{i},1,3)||"."||substr(diag_i_{i},4,2);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else if diag_i_{i} ne '' and length(diag_i_{i}) &amp;lt;=3 then diag_i_{i}=diag_i_{i};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else diag_i_{i}='';&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if icd_flag=10 then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if diag_i_{i} ne '' and length(diag_i_{i}) &amp;gt; 3 then diag_i_{i}=substr(diag_i_{i},1,3)||"."||substr(diag_i_{i},4,7);&lt;BR /&gt;&amp;nbsp;else if diag_i_{i} ne '' and length(diag_i_{i}) &amp;lt;=3 then diag_i_{i}=diag_i_{i};&lt;BR /&gt;&amp;nbsp;else diag_i_{i}='';&lt;BR /&gt;&amp;nbsp; end;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j=1 to 24;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc_i_{j}=compress(proc_i_{j},".");&lt;BR /&gt;&amp;nbsp; if icd_flag=9 then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;do j=1 to 24;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if proc_i_{j} ne '' and length(proc_i_{j}) &amp;gt; 2 then proc_i_{j}=substr(proc_i_{j},1,2)||"."||substr(proc_i_{j},3,2) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else if proc_i_{j} ne '' and length(proc_i_{j}) &amp;lt;= 2 then proc_i_{j}=proc_i_{j};&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else proc_i_{j} ='';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp; if mem_gender='' then mem_gender='U';*/&lt;BR /&gt;&amp;nbsp; if claim_id='' then claim_id ='UNK';&lt;BR /&gt;&amp;nbsp; if claim_type='' then claim_type='UK';&lt;BR /&gt;&amp;nbsp; if units=. then units=1;&lt;BR /&gt;&amp;nbsp; if claim_line_nbr = . then claim_line_nbr=1;&lt;BR /&gt;&amp;nbsp; if product_id= . then product_id=-1;&lt;BR /&gt;/*&amp;nbsp; MED_ELIG_CAT_ID=0;*/&lt;BR /&gt;&amp;nbsp; cvx='';&lt;BR /&gt;&amp;nbsp; CPTII_MOD_1='';&lt;BR /&gt;&amp;nbsp; CPTII_MOD_2='';&lt;BR /&gt;&amp;nbsp; PN_IND='';&lt;BR /&gt;run;&lt;BR /&gt;%mend visit;&lt;/P&gt;&lt;P&gt;%visit(jan,2016);&lt;BR /&gt;%visit(feb,2016);&lt;BR /&gt;%visit(mar,2016);&lt;BR /&gt;%visit(apr,2016);&lt;BR /&gt;%visit(may,2016);&lt;BR /&gt;%visit(jun,2016);&lt;BR /&gt;%visit(jul,2016);&lt;BR /&gt;%visit(aug,2016);&lt;BR /&gt;%visit(sep,2016);&lt;BR /&gt;%visit(oct,2016);&lt;BR /&gt;%visit(nov,2016);&lt;BR /&gt;%visit(dec,2016);&lt;/P&gt;&lt;P&gt;%visit(jan,2017);&lt;BR /&gt;%visit(feb,2017);&lt;BR /&gt;%visit(mar,2017);&lt;BR /&gt;%visit(apr,2017);&lt;BR /&gt;%visit(may,2017);&lt;BR /&gt;%visit(jun,2017);&lt;BR /&gt;%visit(jul,2017);&lt;BR /&gt;%visit(aug,2017);&lt;BR /&gt;%visit(sep,2017);&lt;BR /&gt;%visit(oct,2017);&lt;BR /&gt;%visit(nov,2017);&lt;BR /&gt;%visit(dec,2017);&lt;BR /&gt;%visit(jan,2018);&lt;/P&gt;&lt;P&gt;data out.visit_in_py;&lt;BR /&gt;&amp;nbsp;set&lt;BR /&gt;&amp;nbsp; out.visit_in_jan2016 out.visit_in_feb2016 out.visit_in_mar2016&lt;BR /&gt;&amp;nbsp; out.visit_in_apr2016 out.visit_in_may2016 out.visit_in_jun2016&lt;BR /&gt;&amp;nbsp; out.visit_in_jul2016 out.visit_in_aug2016 out.visit_in_sep2016&lt;BR /&gt;&amp;nbsp; out.visit_in_oct2016 out.visit_in_nov2016 out.visit_in_dec2016&lt;/P&gt;&lt;P&gt;&amp;nbsp; out.visit_in_jan2017 out.visit_in_feb2017 out.visit_in_mar2017&lt;BR /&gt;&amp;nbsp; out.visit_in_apr2017 out.visit_in_may2017 out.visit_in_jun2017&lt;BR /&gt;&amp;nbsp; out.visit_in_jul2017 out.visit_in_aug2017 out.visit_in_sep2017&lt;BR /&gt;&amp;nbsp; out.visit_in_oct2017 out.visit_in_nov2017 out.visit_in_dec2017&lt;/P&gt;&lt;P&gt;&amp;nbsp; out.visit_in_jan2018&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 03:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446524#M112037</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-18T03:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446525#M112038</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find the below I given details for Visit macros. If I normally tested it is creating successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.TEST_JAN2015 has 19 observations and 5 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.01 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.02 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro visit(mon,yr);;&lt;/P&gt;&lt;P&gt;data test_&amp;amp;mon.&amp;amp;yr.;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%visit(jan,2015);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please assist me ?&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 03:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446525#M112038</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-18T03:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446526#M112039</link>
      <description>&lt;P&gt;I have replied to TOM , please find the details about VISIT macros. thank you&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 03:32:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446526#M112039</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-18T03:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446527#M112040</link>
      <description>&lt;P&gt;Inappropriate macro quoting is your problem. Try this simple test program to demonstrate the issue.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(month,year);
data test_&amp;amp;month.&amp;amp;year ;
  x=1;
run;
%mend test;
options mprint;
%test(jan,2017);
%let mon=%qsubstr(jan,1,3);
%test(&amp;amp;mon,2017);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first call works fine.&lt;/P&gt;
&lt;PRE&gt;28   %test(jan,2017);
MPRINT(TEST):   data test_jan2017 ;
MPRINT(TEST):   x=1;
MPRINT(TEST):   run;&lt;/PRE&gt;
&lt;P&gt;The second call seems to generate the right code but SAS is confused by it because of the macro quoting.&lt;/P&gt;
&lt;PRE&gt;29   %let mon=%qsubstr(jan,1,3);
30   %test(&amp;amp;mon,2017);
NOTE: Line generated by the macro variable "DSNAME".
30    test_jan2017
              ----
              22
                ----
                200
MPRINT(TEST):   data test_jan2017 ;
MPRINT(TEST):   x=1;
MPRINT(TEST):   run;

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;,
              _DATA_, _LAST_, _NULL_.

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEST_ may be incomplete.  When this step was stopped there were 0
         observations and 1 variables.
WARNING: The data set WORK.JAN may be incomplete.  When this step was stopped there were 0
         observations and 1 variables.&lt;/PRE&gt;
&lt;P&gt;Two solutions.&lt;/P&gt;
&lt;P&gt;1) Don't add the macro quoting to begin with as it is NOT needed. The three digit codes for months of the year will never contain anything that needs to be macro quoted.&lt;/P&gt;
&lt;P&gt;2) Harden the macro to remove any macro quoting that is passed into it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(month,year);
%local dsname ;
%let dsname=%unquote(test_&amp;amp;month.&amp;amp;year);
data &amp;amp;dsname ;
  x=1;
run;
%mend test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 03:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446527#M112040</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-18T03:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446561#M112049</link>
      <description>&lt;P&gt;I have a visit macro. Which has to be run from Jan 2015 to current month. to avoid&amp;nbsp; manually passing parameter values in visit macro,&lt;/P&gt;&lt;P&gt;how to create in DATA step and CALL execute to loop macros .&lt;/P&gt;&lt;P&gt;Can you please provide me sample code to above scenario?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%visit(&amp;amp;mon.,&amp;amp;yr.);&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 12:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446561#M112049</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-18T12:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446563#M112051</link>
      <description>&lt;P&gt;&lt;STRONG&gt;As per given fist solution, can you please provide me some more clarity on this how to fix my code.&amp;nbsp;because I'm unable to fix it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;it's causing same error.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Don't add the macro quoting to begin with as it is NOT needed. The three digit codes for months of the year will never contain anything that needs to be macro quoted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second solution the one which you given me, we have to pass hardcode&amp;nbsp;manually for each year and months. That's not the case&amp;nbsp;.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 12:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446563#M112051</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-18T12:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446564#M112052</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Please find the below code. Help me how to resolve the issues?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro visit(mon,yr);;&lt;BR /&gt;data test_&amp;amp;mon.&amp;amp;yr.;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;Options macrogen symbolgen mlogic mprint mfile;&lt;BR /&gt;%let startdate= '01Jan2015'd;&lt;BR /&gt;%let Curr_Date= '28FEB2016'd;&lt;BR /&gt;%let Counter = %sysfunc(intck(month,&amp;amp;startdate,&amp;amp;Curr_Date));&lt;BR /&gt;%put &amp;amp;counter.;&lt;BR /&gt;options spool ;&lt;BR /&gt;%macro loop;&lt;BR /&gt;%do i=1 %to &amp;amp;counter.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%let prev_month=%sysfunc(intnx(month,"&amp;amp;startdate"d,-1), date9.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%let date=%sysfunc(intnx(month,"&amp;amp;prev_month"d, &amp;amp;i.), date9.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%put &amp;amp;date.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/*%let month= %sysfunc(month("&amp;amp;date"d));*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/*%let yr= %sysfunc(year("&amp;amp;date"d));*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%GLOBAL yr;&lt;BR /&gt;%LET YR =%qsubstr(&amp;amp;date,6,4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%GLOBAL mon;&lt;BR /&gt;%LET MON =%qsubstr(&amp;amp;date, 3,3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%PUT &amp;amp;MON;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%visit(&amp;amp;mon.,&amp;amp;yr.);&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;BR /&gt;%loop;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 12:34:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446564#M112052</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-18T12:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446571#M112058</link>
      <description>&lt;P&gt;You can either fix the %VISIT() macro by adding an %UNQUOTE() call around the dataset name that is getting broken up because of the macro quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can fix your looping/driver program to NOT add the macro quoting to begin with.&lt;/P&gt;
&lt;P&gt;Change.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET YR =%qsubstr(&amp;amp;date,6,4);
%LET MON =%qsubstr(&amp;amp;date, 3,3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET YR =%substr(&amp;amp;date,6,4);
%LET MON =%substr(&amp;amp;date, 3,3);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Mar 2018 14:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446571#M112058</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-18T14:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: How I do fix the below mentioned SAS Macro Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446575#M112061</link>
      <description>&lt;P&gt;&lt;STRONG&gt;It's working perfect!!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you so much for continuous support to me.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;thank you all. It's a great experience for me..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 15:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-I-do-fix-the-below-mentioned-SAS-Macro-Code/m-p/446575#M112061</guid>
      <dc:creator>Spintu</dc:creator>
      <dc:date>2018-03-18T15:12:21Z</dc:date>
    </item>
  </channel>
</rss>

