<?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: Single quotation in macro variable value causing problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294272#M61376</link>
    <description>&lt;P&gt;Please clarify and show how your using it and how it doesn't work there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use formats such as MONNAME3. And year2 to get the components.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you have folders that have a single quote in the file path?&lt;/P&gt;
&lt;P&gt;Untested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;date=today();&lt;/P&gt;
&lt;P&gt;call symputx('Mmthyy', catx("'", put(date, monname3.), put(date, year2.)));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;mmthyy;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19609"&gt;@JasonNC&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I want to create value as shown below&lt;/P&gt;
&lt;P&gt;Jan'16&lt;/P&gt;
&lt;P&gt;Feb'16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code i created&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let month=%sysfunc(month(%sysfunc(today())));&lt;BR /&gt;%put &amp;amp;month;&lt;BR /&gt;%let year=%sysfunc(year(%sysfunc(strip(%sysfunc(today())))));&lt;BR /&gt;%put &amp;amp;year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format ;&lt;BR /&gt;value month 1='Jan'&lt;BR /&gt;2='Feb'&lt;BR /&gt;3='Mar'&lt;BR /&gt;4='Apr'&lt;BR /&gt;5='May'&lt;BR /&gt;6='Jun'&lt;BR /&gt;7='Jul'&lt;BR /&gt;8='Aug'&lt;BR /&gt;9='Sep'&lt;BR /&gt;10='Oct'&lt;BR /&gt;11='Nov'&lt;BR /&gt;12='Dec'&lt;/P&gt;
&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data _null_;&lt;BR /&gt;Year=put(&amp;amp;year,4.);&lt;BR /&gt;yy=Substr(Year,3,2);&lt;BR /&gt;mth=strip(put(&amp;amp;month.,month.));&lt;BR /&gt;mth_yy=strip(catx("'",mth,yy));&lt;BR /&gt;call symput('Mthyy',mth_yy);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;Mthyy;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;log&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Aug'16;GOPTIONS NOACCESSIBLE;%LET _CLIENTTASKLABEL=;%LET _CLIENTPROJECTPATH=;%LET _CLIENTPROJECTNAME=;%LET _SASPROGRAMFILE=;;*'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It's showing the value but when i am trying to use the value to access the folder it's saying the folder length is 262 charachters long or some thing&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;When i tried removing the single quotation in the macro variable it's working fine.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Can any one look into this asap&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Aug 2016 06:27:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-08-26T06:27:14Z</dc:date>
    <item>
      <title>Single quotation in macro variable value causing problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294265#M61373</link>
      <description>&lt;P&gt;I want to create value as shown below&lt;/P&gt;&lt;P&gt;Jan'16&lt;/P&gt;&lt;P&gt;Feb'16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code i created&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let month=%sysfunc(month(%sysfunc(today())));&lt;BR /&gt;%put &amp;amp;month;&lt;BR /&gt;%let year=%sysfunc(year(%sysfunc(strip(%sysfunc(today())))));&lt;BR /&gt;%put &amp;amp;year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format ;&lt;BR /&gt;value month 1='Jan'&lt;BR /&gt;2='Feb'&lt;BR /&gt;3='Mar'&lt;BR /&gt;4='Apr'&lt;BR /&gt;5='May'&lt;BR /&gt;6='Jun'&lt;BR /&gt;7='Jul'&lt;BR /&gt;8='Aug'&lt;BR /&gt;9='Sep'&lt;BR /&gt;10='Oct'&lt;BR /&gt;11='Nov'&lt;BR /&gt;12='Dec'&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data _null_;&lt;BR /&gt;Year=put(&amp;amp;year,4.);&lt;BR /&gt;yy=Substr(Year,3,2);&lt;BR /&gt;mth=strip(put(&amp;amp;month.,month.));&lt;BR /&gt;mth_yy=strip(catx("'",mth,yy));&lt;BR /&gt;call symput('Mthyy',mth_yy);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%put &amp;amp;Mthyy;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;log&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Aug'16;GOPTIONS NOACCESSIBLE;%LET _CLIENTTASKLABEL=;%LET _CLIENTPROJECTPATH=;%LET _CLIENTPROJECTNAME=;%LET _SASPROGRAMFILE=;;*'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It's showing the value but when i am trying to use the value to access the folder it's saying the folder length is 262 charachters long or some thing&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;When i tried removing the single quotation in the macro variable it's working fine.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Can any one look into this asap&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 06:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294265#M61373</guid>
      <dc:creator>JasonNC</dc:creator>
      <dc:date>2016-08-26T06:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Single quotation in macro variable value causing problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294272#M61376</link>
      <description>&lt;P&gt;Please clarify and show how your using it and how it doesn't work there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use formats such as MONNAME3. And year2 to get the components.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you have folders that have a single quote in the file path?&lt;/P&gt;
&lt;P&gt;Untested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;date=today();&lt;/P&gt;
&lt;P&gt;call symputx('Mmthyy', catx("'", put(date, monname3.), put(date, year2.)));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;mmthyy;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19609"&gt;@JasonNC&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I want to create value as shown below&lt;/P&gt;
&lt;P&gt;Jan'16&lt;/P&gt;
&lt;P&gt;Feb'16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code i created&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let month=%sysfunc(month(%sysfunc(today())));&lt;BR /&gt;%put &amp;amp;month;&lt;BR /&gt;%let year=%sysfunc(year(%sysfunc(strip(%sysfunc(today())))));&lt;BR /&gt;%put &amp;amp;year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format ;&lt;BR /&gt;value month 1='Jan'&lt;BR /&gt;2='Feb'&lt;BR /&gt;3='Mar'&lt;BR /&gt;4='Apr'&lt;BR /&gt;5='May'&lt;BR /&gt;6='Jun'&lt;BR /&gt;7='Jul'&lt;BR /&gt;8='Aug'&lt;BR /&gt;9='Sep'&lt;BR /&gt;10='Oct'&lt;BR /&gt;11='Nov'&lt;BR /&gt;12='Dec'&lt;/P&gt;
&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data _null_;&lt;BR /&gt;Year=put(&amp;amp;year,4.);&lt;BR /&gt;yy=Substr(Year,3,2);&lt;BR /&gt;mth=strip(put(&amp;amp;month.,month.));&lt;BR /&gt;mth_yy=strip(catx("'",mth,yy));&lt;BR /&gt;call symput('Mthyy',mth_yy);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;Mthyy;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;log&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Aug'16;GOPTIONS NOACCESSIBLE;%LET _CLIENTTASKLABEL=;%LET _CLIENTPROJECTPATH=;%LET _CLIENTPROJECTNAME=;%LET _SASPROGRAMFILE=;;*'&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It's showing the value but when i am trying to use the value to access the folder it's saying the folder length is 262 charachters long or some thing&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;When i tried removing the single quotation in the macro variable it's working fine.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Can any one look into this asap&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 06:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294272#M61376</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-26T06:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Single quotation in macro variable value causing problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294274#M61377</link>
      <description>&lt;P&gt;If you actually have folders or filenames containing single quotes, use a &lt;A href="http://www.catb.org/jargon/html/L/LART.html" target="_blank"&gt;LART&lt;/A&gt; on the one who created them in the first way.&lt;/P&gt;
&lt;P&gt;Blanks, quotes and the like have no place in file or directory names, period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your problem comes from the fact that wherever you use your macro variable, a single quote is inserted into the program text (macro is just a text generator!), and what happens thereafter is the same as when you had entered that single quote manually. This also explains the funny layout of the log, as everything that EG does automatically is masked until the "magic line" with ;*';*";*/;quit;run; appears that finally terminates your virtual string; without the magic line your Workspace Server session would become unusable until you sent it a terminating single quote.&lt;/P&gt;
&lt;P&gt;Your string does work if you enlcose it in double quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value _month
  1='Jan'
  2='Feb'
  3='Mar'
  4='Apr'
  5='May'
  6='Jun'
  7='Jul'
  8='Aug'
  9='Sep'
  10='Oct'
  11='Nov'
  12='Dec'
;
run;

data _null_;
year = year(today());
month = month(today());
string = put(month,_month.) !! "'" !! substr(put(year,4.),3,2);
put string=;
call symput('Mthyy',trim(string));
run;

%put "&amp;amp;Mthyy";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I had to use _month for the format name, as SAS already has a format with the name month.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 06:45:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294274#M61377</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-26T06:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Single quotation in macro variable value causing problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294377#M61415</link>
      <description>&lt;P&gt;Try a PICTURE format, then you don't have to mess with all those functions and concatenation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   picture mmmxyy other='%3B''%y' (datatype=date);
   run;
   
data _null_;
   x = today();
   put x=mmmxyy.;
   run;
x=Aug'16
&lt;/CODE&gt;&lt;/PRE&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;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 13:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294377#M61415</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-08-26T13:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Single quotation in macro variable value causing problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294631#M61484</link>
      <description>&lt;P&gt;Looks like you got the value into the macro variable. &amp;nbsp;Your problem is not taking care for how you use it becuase of the single quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you use it in the actual filename it should not be an issue. &amp;nbsp;A statement like&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename in "/mypath/Data for &amp;amp;mthyr.csv";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would work find since the unbalanced single quote will be inside of balanced double quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to view the value using %PUT you will need to either also add quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put "&amp;amp;mthyr";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or add macro quoting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %superq(mthyr);
%put %bquote(&amp;amp;mthyr);
%let mthyr=%superq(mthyr);
%put &amp;amp;mthyr;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Aug 2016 14:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-quotation-in-macro-variable-value-causing-problem/m-p/294631#M61484</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-08-28T14:10:49Z</dc:date>
    </item>
  </channel>
</rss>

