<?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: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/923043#M363419</link>
    <description>&lt;P&gt;You need to defile proper length for expected value of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;qi104&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I guess something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;length qi104&amp;nbsp;$&amp;nbsp;500;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;before line with CATS() function should help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2024 19:48:18 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2024-04-04T19:48:18Z</dc:date>
    <item>
      <title>Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922908#M363373</link>
      <description>&lt;P&gt;Hi! In my data step:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/*Setting Length for redcap_event_name in Databse and Inputting QI Variable Values*/
%let RR=rr100d;
%let RT=rt190; 
data three; 
length id $ 6; 
length record_id $ 30;
length redcap_event_name $ 30; 
set two; 

qi104="Date of scan acquisition on the RT Form (Item 90: &amp;amp;RT) is after the date the radiology review is completed on the RR Form (Item d: &amp;amp;RR).
The date of scan acquisition should be before the date of radiology review. Please review forms for the accuracy of the dates and or return this query with your comments";
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to create a variable, qi104, that pulls in the value of the variables rt190 and rr100d in the quote for each of the observations. Each observation has unique values for rt190 and rr100d. However, it seems that my macro syntax just pulls in the text "rt190" or "rr100d" rather than the value of those respective variables for the quoted string represented by variable qi104. What am I doing wrong? Any input regarding this would be much appreciated. Thanks so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 08:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922908#M363373</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2024-04-04T08:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922910#M363374</link>
      <description>&lt;P&gt;No need for macrovariables here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data three; 
length id $ 6; 
length record_id $ 30;
length redcap_event_name $ 30; 
set two; 

qi104=cats(
"Date of scan acquisition on the RT Form (Item 90: "
,rr100d
,") is after the date the radiology review is completed on the RR Form (Item d: "
,rt190
,"). The date of scan acquisition should be before the date of radiology review. Please review forms for the accuracy of the dates and or return this query with your comments"
);
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A word of explanation.&lt;/P&gt;
&lt;P&gt;Your original code won't do what you expect because macrovariables values were "rr100d" and "rt190" and those values were inserted into the text string. Macrovariables work as a "code text" replacement and a text like: "&lt;EM&gt;blablabal... &lt;STRONG&gt;&amp;amp;RR&lt;/STRONG&gt; ...blablabla&lt;/EM&gt;" is transformed by macroprocessor to:&amp;nbsp;"&lt;EM&gt;blablabal... &lt;STRONG&gt;rr100d&lt;/STRONG&gt; ...blablabla&lt;/EM&gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[EDIT:]&lt;/P&gt;
&lt;P&gt;Read the documetation:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1jgr545j3yz29n1uic9qlvlrzo4.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1jgr545j3yz29n1uic9qlvlrzo4.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_049/sqlproc/p0lsf4btafkw9mn1md4c69kkfwbl.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/v_049/sqlproc/p0lsf4btafkw9mn1md4c69kkfwbl.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;or watch the tutorial:&lt;/P&gt;
&lt;P&gt;3)&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=ODq6V69IX2Y" target="_blank"&gt;https://www.youtube.com/watch?v=ODq6V69IX2Y&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 08:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922910#M363374</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-04T08:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922924#M363376</link>
      <description>&lt;P&gt;Thanks for your help&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;! Does the cats function not seem to agree with particular characters (e.g. parentheses or colons)? For some reason, when I try to run a similar code, qi104 ends up being blank, even though there is no error code saying that it's uninitiated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 09:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922924#M363376</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2024-04-04T09:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922931#M363377</link>
      <description>&lt;P&gt;What "similar code"? Show us the code. Show us the unexpected output. Show us a portion of the data for q104.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 10:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922931#M363377</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-04T10:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922938#M363383</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;already wrote what you should do to get our help...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. the CATS() works like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;result = cats(string1, string2, ..., stringN);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2024 10:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922938#M363383</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-04T10:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922966#M363391</link>
      <description>&lt;P&gt;LOG.&lt;/P&gt;
&lt;P&gt;Show the LOG.&lt;/P&gt;
&lt;P&gt;"Similar" is not the same as Identical.&lt;/P&gt;
&lt;P&gt;Data might be needed but the CATS function is not going to do much of anything except remove leading and trailing spaces when values are combined. A result of blank means that you gave the function blank input or tried to assign a character value to a numeric variable that couldn't be converted to numeric.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 13:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922966#M363391</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-04T13:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922994#M363397</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;, and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;; thanks for your help.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;, your syntax was the one that I did use. My code is as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data three; 
length id $ 6; 
length record_id $ 30;
length redcap_event_name $ 30; 
set two; 
where rt190 &amp;gt; rr100d and rt190 ne . and rr100d ne .; 
rtdate=put(rt190, MMDDYY10.); 
rrdate=put(rr100d, MMDDYY10.); 
number=_n_;
id=put(number, z6.);  
event_id=48807; 
record_id_complete=2; 

if  rr100d &amp;lt;&amp;gt; . then do;
form_letter_1="RR";
page="rr_ct_scan_acquisition_form"; 
end;

if rt190 &amp;lt;&amp;gt; . then do; 
form_letter_2="RT"; 
page="rt_ct_scan_acquisition_form"; 
end; 

qi100a=upcase(redcap_data_access_group); 
qi100c="rt_after_rr";
qi100b=cats(qi100c, '_', id);
record_id=qi100b;
qi100d='02APR2024'd;
qi100e="V01";
qi100q="AXA010";
qi100r=1;
qi101=1;
qi101_s1a=pi100b;
qi101_s1b=pi100c;
qi102___a=1;
qi103___b=1;
qi104=cats('Date of scan acquisition on the RT Form (Item 90: ', rtdate, ')', &lt;BR /&gt;'is after the date the radiology review is completed on the RR Form (Item d:', rrdate, '). ', 'The date of scan acquisition should be before the date of radiology review. Please review forms for the accuracy of the dates and or return this query with your comments.'); 
run; 

proc print data=three; 
var qi104; 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The relevant log is as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;WARNING: In a call to the CATS function, the buffer allocated for the result was not long enough to
         contain the concatenation of all the arguments. The correct result would contain 317
         characters, but the actual result might either be truncated to 200 character(s) or be
         completely blank, depending on the calling environment. The following note indicates the
         left-most argument that caused truncation.
NOTE: Argument 7 to function CATS('Date of scan'[12 of 50 characters shown],'04/22/2023',')','is
      after the'[12 of 75 characters shown],'04/22/1996','). ','The date of '[12 of 170 characters
      shown]) at line 2877 column 7 is invalid.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 14:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922994#M363397</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2024-04-04T14:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922998#M363400</link>
      <description>&lt;P&gt;If you don't define you variables, like qi104, then SAS is forced to GUESS how you intended them to be defined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks it guessed to make it too short for the strings you are trying to store in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to know how to define variables since you are doing it for&amp;nbsp;id, record_id and&amp;nbsp;redcap_event_name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 15:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/922998#M363400</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-04T15:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/923014#M363406</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, many thanks for your help! It seems to be a length issue for the concatenated variable. Would you recommend that I pre-define the length of the variable where I am trying to concatenate various strings of text? Thanks again for your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 17:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/923014#M363406</guid>
      <dc:creator>JackZ295</dc:creator>
      <dc:date>2024-04-04T17:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/923026#M363412</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213376"&gt;@JackZ295&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, many thanks for your help! It seems to be a length issue for the concatenated variable. Would you recommend that I pre-define the length of the variable where I am trying to concatenate various strings of text? Thanks again for your help!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes.&amp;nbsp; You should be able to define a length that is longer than any possible value your code will try to store in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general you should define your character variables instead of letting SAS guess what length they need.&amp;nbsp; When it guesses it will usually guess a length of either 8 or 200 bytes when there is no other clear basis for it to choose something else.&amp;nbsp; In your example it is probably choosing $200 and that is ending up being too short.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 18:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/923026#M363412</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-04T18:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Question Regarding How to Utilize Macro Variables to Insert Variable Values in Quoted String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/923043#M363419</link>
      <description>&lt;P&gt;You need to defile proper length for expected value of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;qi104&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I guess something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;length qi104&amp;nbsp;$&amp;nbsp;500;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;before line with CATS() function should help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 19:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-Regarding-How-to-Utilize-Macro-Variables-to-Insert/m-p/923043#M363419</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-04T19:48:18Z</dc:date>
    </item>
  </channel>
</rss>

