<?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 use 'tranwrd' function in a Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684299#M207348</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using 'tranwrd' function in a Macro, and expect to set '&lt;STRONG&gt;&amp;amp;level.' &lt;/STRONG&gt;as &lt;STRONG&gt;'Rating&lt;/STRONG&gt;' in the tranwrd function. Could you please tell me how to do it? I have tried to use ', '', "", but all does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%MACRO sheet(level=,);
data SP_sheet1(keep=SP_Entity_ID SP_ECR_&amp;amp;level. &amp;amp;level. &amp;amp;level._range);
	Length
	SP_Entity_ID $100.
	SP_ECR_&amp;amp;level. $2500.
	SP_ECR_History2 $2500.
	SP_ECR_History3 $3500.
	&amp;amp;level. $50.
	&amp;amp;level._range $200.
	;
	set original_table(drop= LEI_CICI SIC_:);
	SP_Entity_ID=S_P_Entity_ID;
	SP_ECR_&amp;amp;level.=S_P_Entity_Credit_Rating_History;
	SP_ECR_History2=S_P_Entity_Credit_Rating_Histor1;
	SP_ECR_History3=S_P_Entity_Credit_Rating_Histor2;
	SP_ECR_&amp;amp;level.=tranwrd(SP_ECR_&amp;amp;level.,'0D0A'x, ','); 
	SP_ECR_&amp;amp;level.=tranwrd(SP_ECR_&amp;amp;level.,',,', ','); 
	count=countc(SP_ECR_&amp;amp;level.,",")+1;
  do i=1 to count by 2;
  &lt;STRONG&gt;&amp;amp;level.=strip(tranwrd(scan(SP_ECR_&amp;amp;level.,i,','),'&amp;amp;level. :',''));
  &amp;amp;level._range=strip(tranwrd(scan(SP_ECR_&amp;amp;level.,i+1,','),'&amp;amp;level. Range:',''));&lt;/STRONG&gt;
  output;
 end; 
run;
%MEND sheet;
%sheet(level=Rating)
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Sep 2020 16:00:53 GMT</pubDate>
    <dc:creator>Alexxxxxxx</dc:creator>
    <dc:date>2020-09-16T16:00:53Z</dc:date>
    <item>
      <title>use 'tranwrd' function in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684299#M207348</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using 'tranwrd' function in a Macro, and expect to set '&lt;STRONG&gt;&amp;amp;level.' &lt;/STRONG&gt;as &lt;STRONG&gt;'Rating&lt;/STRONG&gt;' in the tranwrd function. Could you please tell me how to do it? I have tried to use ', '', "", but all does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%MACRO sheet(level=,);
data SP_sheet1(keep=SP_Entity_ID SP_ECR_&amp;amp;level. &amp;amp;level. &amp;amp;level._range);
	Length
	SP_Entity_ID $100.
	SP_ECR_&amp;amp;level. $2500.
	SP_ECR_History2 $2500.
	SP_ECR_History3 $3500.
	&amp;amp;level. $50.
	&amp;amp;level._range $200.
	;
	set original_table(drop= LEI_CICI SIC_:);
	SP_Entity_ID=S_P_Entity_ID;
	SP_ECR_&amp;amp;level.=S_P_Entity_Credit_Rating_History;
	SP_ECR_History2=S_P_Entity_Credit_Rating_Histor1;
	SP_ECR_History3=S_P_Entity_Credit_Rating_Histor2;
	SP_ECR_&amp;amp;level.=tranwrd(SP_ECR_&amp;amp;level.,'0D0A'x, ','); 
	SP_ECR_&amp;amp;level.=tranwrd(SP_ECR_&amp;amp;level.,',,', ','); 
	count=countc(SP_ECR_&amp;amp;level.,",")+1;
  do i=1 to count by 2;
  &lt;STRONG&gt;&amp;amp;level.=strip(tranwrd(scan(SP_ECR_&amp;amp;level.,i,','),'&amp;amp;level. :',''));
  &amp;amp;level._range=strip(tranwrd(scan(SP_ECR_&amp;amp;level.,i+1,','),'&amp;amp;level. Range:',''));&lt;/STRONG&gt;
  output;
 end; 
run;
%MEND sheet;
%sheet(level=Rating)
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 16:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684299#M207348</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2020-09-16T16:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: use 'tranwrd' function in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684302#M207350</link>
      <description>You cannot use normal functions on macro variables. They have to be macro functions. I am not aware of %tranwrd, so it would probably have to be %sysfunc(tranword for macro processor to recognize it. Please also check out this post:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-macro-variable-through-tranwrd-function-for-each/td-p/432939" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-pass-a-macro-variable-through-tranwrd-function-for-each/td-p/432939&lt;/A&gt;</description>
      <pubDate>Wed, 16 Sep 2020 16:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684302#M207350</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2020-09-16T16:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: use 'tranwrd' function in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684304#M207352</link>
      <description>&lt;P&gt;Any time you enclose in single quotes some text which includes a macro variable, the macro variable will not resolve. You must use double quotes.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 16:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684304#M207352</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-16T16:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: use 'tranwrd' function in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684321#M207364</link>
      <description>&lt;P&gt;I would like to demonstrate&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s note:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;level.=strip(&lt;STRONG&gt;tranwrd&lt;/STRONG&gt;(scan(SP_ECR_&amp;amp;level.,i,','),&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&amp;amp;level. :'&lt;/STRONG&gt;&lt;/FONT&gt;,''));&lt;BR /&gt;&amp;amp;level._range=strip(&lt;STRONG&gt;tranwrd&lt;/STRONG&gt;(scan(SP_ECR_&amp;amp;level.,i+1,','),&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&amp;amp;level. Range:'&lt;/STRONG&gt;&lt;/FONT&gt;,''));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;FONT color="#FF0000"&gt;RED&lt;/FONT&gt; strings should be enclosed with double-quote and not single quots.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;level.=strip(tranwrd(scan(SP_ECR_&amp;amp;level.,i,','),&lt;FONT color="#008000"&gt;&lt;STRONG&gt;"&amp;amp;level. :"&lt;/STRONG&gt;&lt;/FONT&gt;,''));&lt;BR /&gt;&amp;amp;level._range=strip(tranwrd(scan(SP_ECR_&amp;amp;level.,i+1,','),&lt;FONT color="#008000"&gt;&lt;STRONG&gt;"&amp;amp;level. Range:"&lt;/STRONG&gt;&lt;/FONT&gt;,''));&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 17:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/use-tranwrd-function-in-a-Macro/m-p/684321#M207364</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-16T17:09:06Z</dc:date>
    </item>
  </channel>
</rss>

