<?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: Appending SAS function while resolving the macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600116#M173385</link>
    <description>&lt;P&gt;What is the CASHFLOW_DT variable?&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a numeric variable that contains date values (number of days since 1960)?&amp;nbsp; If so then want PUT(CASHFLOW_DT,DATE9.) instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a character variable that contains values that look like dates, like 2018-07-31 or 07/31/2018, then use the appropriate informat for the type of date strings it has.&amp;nbsp; PUT(input(CASHFLOW_DT,YYMMDD10.),DATE9.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a character variable that contains date value as a string of digits, like&amp;nbsp;21396 which would be '31JUL2018'd, then add an input() function call.&amp;nbsp;&amp;nbsp;PUT(input(CASHFLOW_DT,32.),DATE9.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a numeric variable that contains numbers that look like dates in either YMD order, like 20180731, or MDY order like 07312018, or DMY order like 31072018 then you will need a triple sandwich to convert the number to a string, then to date and finally back to string.&amp;nbsp;PUT(input(PUT(CASHFLOW_DT,z8.),YYMMDD8.),DATE9.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is a number with date values and already has the DATE9. format attached to it and you are using the generated code in a data step then use the VVALUE() function.&amp;nbsp; VVALUE(CASHFLOW_DT).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whatever syntax you need to generate just use the TRANWRD() function to convert your existing string to the new string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let new_business_key=%sysfunc(tranwrd(&amp;amp;business_key),VVALUE(CASHFLOW_DT),CASHFLOW_DT));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Oct 2019 16:59:32 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-10-29T16:59:32Z</dc:date>
    <item>
      <title>Appending SAS function while resolving the macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600045#M173346</link>
      <description>&lt;P&gt;I've a macro variable which resolves as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	%put &amp;amp;business_key;

CASHFLOW_DT|| '  |  ' || CASHFLOW_CD|| '  |  ' || NAME&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If there is _DT in the value of the macro variable then either I need the macro variable to resolve as below or recreate another macro variable as shown below. _DT value can come at any position or sometimes it will not come as it depends on source&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cats(put(input(CASHFLOW_DT, 8.), date9.)|| '  |  ' || CASHFLOW_CD|| '  |  ' || NAME&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 12:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600045#M173346</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-29T12:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Appending SAS function while resolving the macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600071#M173361</link>
      <description>&lt;P&gt;You are submitting the va&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;riable CASHFLOW_DT to an input function in the expression&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN class="token keyword" style="background-attachment: scroll; background-clip: border-box; background-color: #ffffff; background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; box-sizing: inherit; color: blue; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: inherit; color: #999999; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 1em; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt;CASHFLOW_DT&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: inherit; color: #999999; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number" style="box-sizing: inherit; color: #008080; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;8&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: inherit; color: #999999; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: inherit; color: #999999; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This means the CASHFLOW_DT is a character variable.&amp;nbsp; And the character value is a series of numeric characters representing the number of days after 01jan1960.&amp;nbsp; I doubt that is your situation. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give some example of the values of the constituent variables, and what the corresponding business key would produce if executed.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 14:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600071#M173361</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-29T14:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Appending SAS function while resolving the macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600116#M173385</link>
      <description>&lt;P&gt;What is the CASHFLOW_DT variable?&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a numeric variable that contains date values (number of days since 1960)?&amp;nbsp; If so then want PUT(CASHFLOW_DT,DATE9.) instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a character variable that contains values that look like dates, like 2018-07-31 or 07/31/2018, then use the appropriate informat for the type of date strings it has.&amp;nbsp; PUT(input(CASHFLOW_DT,YYMMDD10.),DATE9.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a character variable that contains date value as a string of digits, like&amp;nbsp;21396 which would be '31JUL2018'd, then add an input() function call.&amp;nbsp;&amp;nbsp;PUT(input(CASHFLOW_DT,32.),DATE9.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it a numeric variable that contains numbers that look like dates in either YMD order, like 20180731, or MDY order like 07312018, or DMY order like 31072018 then you will need a triple sandwich to convert the number to a string, then to date and finally back to string.&amp;nbsp;PUT(input(PUT(CASHFLOW_DT,z8.),YYMMDD8.),DATE9.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is a number with date values and already has the DATE9. format attached to it and you are using the generated code in a data step then use the VVALUE() function.&amp;nbsp; VVALUE(CASHFLOW_DT).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whatever syntax you need to generate just use the TRANWRD() function to convert your existing string to the new string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let new_business_key=%sysfunc(tranwrd(&amp;amp;business_key),VVALUE(CASHFLOW_DT),CASHFLOW_DT));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 16:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600116#M173385</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-29T16:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Appending SAS function while resolving the macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600213#M173427</link>
      <description>&lt;P&gt;I'm going to guess that you are merely trying to change the formula, but not computing anything yet.&amp;nbsp; Only when the macro variable gets used at a later point will you compute anything.&amp;nbsp; If that's right, then you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
if index("&amp;amp;business_key", '_DT') then call symput 

('business_key', "cats(put(input(CASHFLOW_DT, 8.), date9.)|| '  |  ' || CASHFLOW_CD|| '  |  ' || NAME" ) ;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That replaces &amp;amp;business_key.&amp;nbsp; If you want a different macro variable instead, change the first parameter to CALL SYMPUT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 23:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600213#M173427</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-10-29T23:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Appending SAS function while resolving the macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600331#M173502</link>
      <description>&lt;P&gt;Sounds quite simple, just use a TRANWRD function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let business_key=CASHFLOW_DT|| '  |  ' || CASHFLOW_CD|| '  |  ' || NAME;
%put &amp;amp;business_key;
%let business_key=%sysfunc(tranwrd(&amp;amp;Business_key,CASHFLOW_DT,put(input(CASHFLOW_DT, 8.), date9.)));
%put &amp;amp;business_key;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although I do not understand where the CATS function in your example comes in, am I missing something?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 11:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600331#M173502</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-10-30T11:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Appending SAS function while resolving the macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600408#M173549</link>
      <description>Instead of hardcoding like 'CASHFLOW_DT', can we do with wildcards like&lt;BR /&gt;%'_DT'%? Because it might be any variable which ends with _DT where I want&lt;BR /&gt;to implement this mechanism.&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Oct 2019 14:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-SAS-function-while-resolving-the-macro-variable/m-p/600408#M173549</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-30T14:22:19Z</dc:date>
    </item>
  </channel>
</rss>

