<?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: Splitting a macro variable into smaller macro variables. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517420#M139885</link>
    <description>&lt;P&gt;Sorry, is this some kind of joke?&amp;nbsp; You have provided a string and asked to split the string,&amp;nbsp;only including the parts of the string that indicate variables.&amp;nbsp; Thus I removed that part of the string which is not pertinent to the requested output.&amp;nbsp; How is this bad practice?&amp;nbsp; Its simple string manipulation to get the required output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is bad practice is putting metadata in a macro variable in the first place and then trying to process it afterwards.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As such good luck with programming, I am out of this discussion.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Nov 2018 11:29:26 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-11-30T11:29:26Z</dc:date>
    <item>
      <title>Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516976#M139672</link>
      <description>&lt;P&gt;&amp;nbsp;I have a macro variable like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MACRO&amp;nbsp;+ Intercept [0.1921215597] + CHAR6 [0.3071353419] + CHAR9 [0.4431909076] + CHAR11 [0.2608270872] + CHAR783 [0.3223002876] + CHAR913 [0.3977991533] + CHAR741 [0.9413739214] + WOE_CHARX3 [0.2782062893]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to split it into this form:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR1 CHAR6&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;VAR7 CHARX3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 09:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516976#M139672</guid>
      <dc:creator>meighanj</dc:creator>
      <dc:date>2018-11-29T09:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516979#M139675</link>
      <description>&lt;P&gt;You don't say anything about what is going on around that or the process, so I just guess you want a dataset out:&lt;/P&gt;
&lt;PRE&gt;%let m=MACRO + Intercept [0.1921215597] + CHAR6 [0.3071353419] + CHAR9 [0.4431909076] + CHAR11 [0.2608270872] + CHAR783 [0.3223002876] + CHAR913 [0.3977991533] + CHAR741 [0.9413739214] + WOE_CHARX3 [0.2782062893];&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; length str wrd $2000;&lt;BR /&gt; str=tranwrd("&amp;amp;m.","MACRO + Intercept [0.1921215597] + ","");&lt;BR /&gt; do i=1 to countw(str,"+");&lt;BR /&gt;   wrd=scan(str,i,"+");&lt;BR /&gt;   wrd=cat("VAR",strip(put(i,best.))," ",substr(wrd,1,index(wrd,"[")-1));&lt;BR /&gt;   output;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;Which begs the question why that string is in a macro variable in the first place.&amp;nbsp; The place for storing data is in a dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 10:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516979#M139675</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-29T10:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516991#M139679</link>
      <description>&lt;P&gt;From where do you get that macro variable in the first place? Data has to be kept in datasets, that is the natural habitat.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 11:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516991#M139679</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-29T11:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516993#M139680</link>
      <description>&lt;P&gt;Ok, so I created the macro from a variable in a data-set. So, it would be easier if I don't create the macro in the first place? How could I do it if it is a variable in a data-set?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 11:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516993#M139680</guid>
      <dc:creator>meighanj</dc:creator>
      <dc:date>2018-11-29T11:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516996#M139681</link>
      <description>&lt;P&gt;How does the original dataset look like? Please post an example of it in a readily usable form (data step with datalines).&lt;/P&gt;
&lt;P&gt;And how do you intend to use the wanted result that you posted in your initial question?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 11:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/516996#M139681</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-29T11:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517011#M139691</link>
      <description>&lt;P&gt;I have shown you above, just remove the macro part, and set your dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 12:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517011#M139691</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-29T12:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517042#M139710</link>
      <description>&lt;P&gt;I propose this solution:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var=MACRO + Intercept [0.1921215597] + CHAR6 [0.3071353419] + 
        CHAR9 [0.4431909076] + CHAR11 [0.2608270872] + CHAR783 [0.3223002876] + CHAR913 [0.3977991533] + CHAR741 [0.9413739214] + WOE_CHARX3 [0.2782062893];

option symbolgen mprint mlogic;

%macro t;

%do i=1 %to %sysfunc(countw(&amp;amp;var,'+'));
%global var&amp;amp;i ;

%if    %sysfunc(substr(%sysfunc(scan(&amp;amp;var,&amp;amp;i,'+')),1,4)) eq CHAR %then  

      %let var&amp;amp;i=%sysfunc(scan(%sysfunc(scan(&amp;amp;var,&amp;amp;i,'+')),1%str()));
	

%end;

%mend t;

%t;

%put _all_;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 13:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517042#M139710</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-11-29T13:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517412#M139879</link>
      <description>&lt;P&gt;I don't want the Intercept to be one of the macro variables. Nice try though.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 10:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517412#M139879</guid>
      <dc:creator>meighanj</dc:creator>
      <dc:date>2018-11-30T10:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517416#M139882</link>
      <description>&lt;P&gt;The code does not include the intercept, clearly shown by the code line:&lt;/P&gt;
&lt;PRE&gt; str=tranwrd("&amp;amp;m.","MACRO + Intercept [0.1921215597] + ","");&lt;/PRE&gt;
&lt;P&gt;So what does my code not do then?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 11:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517416#M139882</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-30T11:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517417#M139883</link>
      <description>&lt;P&gt;Ok, I realise now. You hardcoded the intercept co-efficient, very bad practise.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 11:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517417#M139883</guid>
      <dc:creator>meighanj</dc:creator>
      <dc:date>2018-11-30T11:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517418#M139884</link>
      <description>&lt;P&gt;Close but you fail on the last variable which doesn't start with char&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 11:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517418#M139884</guid>
      <dc:creator>meighanj</dc:creator>
      <dc:date>2018-11-30T11:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a macro variable into smaller macro variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517420#M139885</link>
      <description>&lt;P&gt;Sorry, is this some kind of joke?&amp;nbsp; You have provided a string and asked to split the string,&amp;nbsp;only including the parts of the string that indicate variables.&amp;nbsp; Thus I removed that part of the string which is not pertinent to the requested output.&amp;nbsp; How is this bad practice?&amp;nbsp; Its simple string manipulation to get the required output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is bad practice is putting metadata in a macro variable in the first place and then trying to process it afterwards.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As such good luck with programming, I am out of this discussion.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 11:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-macro-variable-into-smaller-macro-variables/m-p/517420#M139885</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-30T11:29:26Z</dc:date>
    </item>
  </channel>
</rss>

