<?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 SUBSTR, CALL SYMPUT, and years 1999 &amp;amp; 2000 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/403983#M98192</link>
    <description>&lt;P&gt;This is surely an FAQ.&amp;nbsp; I'm passing a year (1999 or 2000) into a SAS program.&amp;nbsp; Everything works fine for 1999:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yyyy;&lt;BR /&gt;1999&lt;BR /&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET yy=%SUBSTR(&amp;amp;yyyy,3);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* last two digits of yyyy */&lt;BR /&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yy;&lt;BR /&gt;99&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA _null_;&lt;BR /&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL SYMPUT('fpath', cat("/wrds/taq.",&amp;amp;yyyy,"/taq",&amp;amp;yy,"d/sasdata"));&lt;BR /&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp; RUN;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;fpath;&lt;BR /&gt;/wrds/taq.1999/taq99d/sasdata&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but fails for 2000:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yyyy;&lt;BR /&gt;2000&lt;BR /&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET yy=%SUBSTR(&amp;amp;yyyy,3);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* last two digits of yyyy */&lt;BR /&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yy;&lt;BR /&gt;00&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA _null_;&lt;BR /&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL SYMPUT('fpath', cat("/wrds/taq.",&amp;amp;yyyy,"/taq",&amp;amp;yy,"d/sasdata"));&lt;BR /&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp; RUN;&lt;BR /&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;fpath;&lt;BR /&gt;/wrds/taq.2000/taq0d/sasdata&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need the final character string to be "/wrds/taq.2000/taq00d/sasdata" (two zeros before d, not one!)&amp;nbsp; For some reason, &amp;amp;yy doesn't give me 00 when it appears within the&amp;nbsp;CALL SYMPUT argument list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How, please, can I fix this problem?&amp;nbsp; Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 13 Oct 2017 15:36:14 GMT</pubDate>
    <dc:creator>sfinch</dc:creator>
    <dc:date>2017-10-13T15:36:14Z</dc:date>
    <item>
      <title>SUBSTR, CALL SYMPUT, and years 1999 &amp; 2000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/403983#M98192</link>
      <description>&lt;P&gt;This is surely an FAQ.&amp;nbsp; I'm passing a year (1999 or 2000) into a SAS program.&amp;nbsp; Everything works fine for 1999:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yyyy;&lt;BR /&gt;1999&lt;BR /&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET yy=%SUBSTR(&amp;amp;yyyy,3);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* last two digits of yyyy */&lt;BR /&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yy;&lt;BR /&gt;99&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA _null_;&lt;BR /&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL SYMPUT('fpath', cat("/wrds/taq.",&amp;amp;yyyy,"/taq",&amp;amp;yy,"d/sasdata"));&lt;BR /&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp; RUN;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;fpath;&lt;BR /&gt;/wrds/taq.1999/taq99d/sasdata&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but fails for 2000:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yyyy;&lt;BR /&gt;2000&lt;BR /&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET yy=%SUBSTR(&amp;amp;yyyy,3);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* last two digits of yyyy */&lt;BR /&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;yy;&lt;BR /&gt;00&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA _null_;&lt;BR /&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL SYMPUT('fpath', cat("/wrds/taq.",&amp;amp;yyyy,"/taq",&amp;amp;yy,"d/sasdata"));&lt;BR /&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp; RUN;&lt;BR /&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;fpath;&lt;BR /&gt;/wrds/taq.2000/taq0d/sasdata&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need the final character string to be "/wrds/taq.2000/taq00d/sasdata" (two zeros before d, not one!)&amp;nbsp; For some reason, &amp;amp;yy doesn't give me 00 when it appears within the&amp;nbsp;CALL SYMPUT argument list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How, please, can I fix this problem?&amp;nbsp; Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 15:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/403983#M98192</guid>
      <dc:creator>sfinch</dc:creator>
      <dc:date>2017-10-13T15:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR, CALL SYMPUT, and years 1999 &amp; 2000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/403988#M98193</link>
      <description>&lt;P&gt;CAT automatically converts numbers using the BEST format. 99 stays 99, but 00 becomes 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use an explicit format instead, ie PUT(..., Z2.)&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 15:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/403988#M98193</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-13T15:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR, CALL SYMPUT, and years 1999 &amp; 2000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/403994#M98197</link>
      <description>&lt;P&gt;Besides making it way to too complicate the offending element is in this line:&lt;/P&gt;
&lt;P&gt;CALL SYMPUT('fpath', cat("/wrds/taq.",&amp;amp;yyyy,"/taq",&amp;amp;yy,"d/sasdata"));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you do not have &amp;amp;yy in quotes it is treated as a numeric value and the CAT function uses the BEST format to turn the numeric into a text value to concatenate. So is equivalent to ,put(&amp;amp;yy, best8.) which generates a 0.&lt;/P&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; Fpath = /wrds/taq&amp;amp;yyyy,/taq&lt;/FONT&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%substr&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;(&amp;amp;yyyy,3,2)d/sasdata;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;The macro concatenation works just fine no data step, no call symput and no data step functions needed&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 15:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/403994#M98197</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-13T15:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR, CALL SYMPUT, and years 1999 &amp; 2000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404006#M98203</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Your command&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%LET fpath = /wrds/taq.&amp;amp;yyyy/taq%SUBSTR(&amp;amp;yyyy,3,2)d/sasdata;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;works perfectly: thank you!&amp;nbsp; It certainly is more concise as well.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Looking back at my code, why does SAS treat &amp;amp;yyyy differently than &amp;amp;yy?&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;While PUT(&amp;amp;yy,Z2.) was necessary to format &amp;amp;yy correctly, &amp;amp;yyyy required no additional intervention.&amp;nbsp; This asymmetry is puzzling to me.&amp;nbsp; Is an explanation possible?&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 16:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404006#M98203</guid>
      <dc:creator>sfinch</dc:creator>
      <dc:date>2017-10-13T16:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR, CALL SYMPUT, and years 1999 &amp; 2000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404017#M98208</link>
      <description>&lt;P&gt;Pass &amp;amp;YY to the CAT() function as a string and not a number.&amp;nbsp; So use "&amp;amp;YY" instead of just &amp;amp;YY.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _null_;
  CALL SYMPUT('fpath', cat("/wrds/taq.","&amp;amp;yyyy","/taq","&amp;amp;yy","d/sasdata"));
RUN;   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that there is no real need to use CAT() function for macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fpath =/wrds/taq.&amp;amp;yyyy./taq&amp;amp;yy.d/sasdata ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To see what CAT() is doing with the number try a little experiment yourself.&lt;/P&gt;
&lt;PRE&gt;17   data _null_;
18     do num=9 to 10;
19       str=put(num,z2.);
20       length catnum catstr $100;
21       catnum=cats('before',num,'after');
22       catstr=cats('before',str,'after');
23       put (_all_) (=/);
24     end;
25   run;


num=9
str=09
catnum=before9after
catstr=before09after

num=10
str=10
catnum=before10after
catstr=before10after&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 16:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404017#M98208</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-13T16:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR, CALL SYMPUT, and years 1999 &amp; 2000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404024#M98210</link>
      <description>&lt;P&gt;Thank you most kindly!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 16:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404024#M98210</guid>
      <dc:creator>sfinch</dc:creator>
      <dc:date>2017-10-13T16:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: SUBSTR, CALL SYMPUT, and years 1999 &amp; 2000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404027#M98211</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169811"&gt;@sfinch&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Your command&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%LET fpath = /wrds/taq.&amp;amp;yyyy/taq%SUBSTR(&amp;amp;yyyy,3,2)d/sasdata;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;works perfectly: thank you!&amp;nbsp; It certainly is more concise as well.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Looking back at my code, why does SAS treat &amp;amp;yyyy differently than &amp;amp;yy?&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;While PUT(&amp;amp;yy,Z2.) was necessary to format &amp;amp;yy correctly, &amp;amp;yyyy required no additional intervention.&amp;nbsp; This asymmetry is puzzling to me.&amp;nbsp; Is an explanation possible?&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try it with YYYY=0000 and it will do the same thing. Since your values for YYYY were likely to be in 19xx or 20xx or such range then the first significant digit appears in the first of 4 digits.&lt;/P&gt;
&lt;P&gt;Or try YY = 0015, you'll get 15 in the output for the &amp;amp;yyyy for the same reason: conversion using best. format.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 16:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUBSTR-CALL-SYMPUT-and-years-1999-amp-2000/m-p/404027#M98211</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-13T16:51:07Z</dc:date>
    </item>
  </channel>
</rss>

