<?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: How to read a macro variable value and convert it in  SAS data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858927#M339372</link>
    <description>&lt;P&gt;This way gets rid of those pesky blanks that occur:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	var = "&amp;amp;x.";
	do i = 1 to countw(var, ",");
		wantvar = scan(compress(var), i, ",");
		output;
	end;
	drop var i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Feb 2023 13:28:04 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2023-02-15T13:28:04Z</dc:date>
    <item>
      <title>How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858922#M339369</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a macro variable having values&amp;nbsp; like below seprated by ","&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let x =&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;%nrstr(f588c556-15c4-4d59-b9df-88b2c655a950,06d54597-fc35-459b-bc5e-&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1075e9643a1d,06d54597-fc35-459b-bc5e-2137e9643a1d);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;I want to create a SAS data set using these values&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;so output should&amp;nbsp;be&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;table out&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;f588c556-15c4-4d59-b9df-88b2c655a950&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;06d54597-fc35-459b-bc5e-1075e9643a1d&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;06d54597-fc35-459b-bc5e-2137e9643a1d&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;I need table out so I can run query on Table out as it is required in further&amp;nbsp;steps.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ud b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;I need your help in understanding , How to created table OUT from macro variable X.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 12:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858922#M339369</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2023-02-15T12:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858926#M339371</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327170"&gt;@Aexor&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can put the macro variable reference &lt;FONT face="courier new,courier"&gt;&amp;amp;x&lt;/FONT&gt; into double quotes and then work with it as you would with any other constant string, i.e., use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p18xi2516ihygyn1qg1b1nby326k.htm" target="_blank" rel="noopener"&gt;COUNTW&lt;/A&gt; and &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_blank" rel="noopener"&gt;SCAN&lt;/A&gt; function to count and extract the comma-separated substrings:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
length c $36;
do _n_=1 to countw("&amp;amp;x", ',');
  c=scan("&amp;amp;x", _n_, ',');
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure that the length of the character variable (named &lt;FONT face="courier new,courier"&gt;c&lt;/FONT&gt; in the example above) is sufficient to accommodate the longest substring.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I would ask how these strings -- separated by "," -- got into a macro variable in the first place. In many cases it should be possible to get the strings into a SAS dataset directly from their source, without using macro variables for intermediate storage.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 13:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858926#M339371</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-02-15T13:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858927#M339372</link>
      <description>&lt;P&gt;This way gets rid of those pesky blanks that occur:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	var = "&amp;amp;x.";
	do i = 1 to countw(var, ",");
		wantvar = scan(compress(var), i, ",");
		output;
	end;
	drop var i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2023 13:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858927#M339372</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2023-02-15T13:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858963#M339390</link>
      <description>Thank you. Also I have one doubt. will this &amp;amp;x will this  be able to store around 2000 observation values , like here we have 3 observation only separated by comma&lt;BR /&gt;&lt;BR /&gt;%let x =%nrstr(f588c556-15c4-4d59-b9df-88b2c655a950,06d54597-fc35-459b-bc5e-        1075e9643a1d,06d54597-fc35-459b-bc5e-2137e9643a1d);</description>
      <pubDate>Wed, 15 Feb 2023 15:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858963#M339390</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2023-02-15T15:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858964#M339391</link>
      <description>Thank you. This worked. Just have doubt about limitation of number of observation can be stored in X macro variable using %let .&lt;BR /&gt;here in example I have mentioned only 3 observation. I need to store around 2000 to 3000 observation in this. will this work ?</description>
      <pubDate>Wed, 15 Feb 2023 15:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858964#M339391</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2023-02-15T15:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858966#M339393</link>
      <description>&lt;P&gt;Not tested, but something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let x =%nrstr(f588c556-15c4-4d59-b9df-88b2c655a950,06d54597-fc35-459b-bc5e-1075e9643a1d,06d54597-fc35-459b-bc5e-2137e9643a1d);

data want;
  do i =1 to countw("&amp;amp;x.",",");   
    result=scan("&amp;amp;x.",i,",");
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Essentially count how many comma separated items, then substr each by delimiter comma and output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To add, macro variables are not th eplace to store data, there are many ways to store it, json, xml, datasets etc.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 15:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858966#M339393</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2023-02-15T15:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858976#M339398</link>
      <description>&lt;P&gt;To your question about the limits of a macro variable:&lt;BR /&gt;A macro variable can contain up to 64K bytes.&amp;nbsp; But a data step character variable can only contain up to 32K bytes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your items seem to be of length 36 bytes.&amp;nbsp; So with a one byte delimiter you could store 1,771 of them.&lt;/P&gt;
&lt;PRE&gt;1698  %put %length(f588c556-15c4-4d59-b9df-88b2c655a950);
36
1699  %put %eval(64*1024/37);
1771&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you really intend to type out 64K characters to create a macro variable?&amp;nbsp; Why not just type them as data instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input code $36.;
cards;
f588c556-15c4-4d59-b9df-88b2c655a950
06d54597-fc35-459b-bc5e-1075e9643a1d
06d54597-fc35-459b-bc5e-2137e9643a1d
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are not typing them into the code then explain where the list of codes is coming from.&amp;nbsp; It would probably be a lot easier to just leave the code in data rather than try to stuff them into a macro variable (or even multiple macro variables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 15:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858976#M339398</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-15T15:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858977#M339399</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327170"&gt;@Aexor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;... I have one doubt. will this &amp;amp;x will this be able to store around 2000 observation values , like here we have 3 observation only separated by comma&lt;BR /&gt;&lt;BR /&gt;%let x =%nrstr(f588c556-15c4-4d59-b9df-88b2c655a950,06d54597-fc35-459b-bc5e- 1075e9643a1d,06d54597-fc35-459b-bc5e-2137e9643a1d);&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If each of those "observation values" has a length of 36 characters like your example strings, then you can store up to 1771 of them, separated by commas, in a single macro variable. Adding one more would exceed the maximum length of a macro variable value, which is 65,534 characters: &lt;FONT face="courier new,courier"&gt;1772*(36+1)-1=65563&lt;/FONT&gt;. This limitation is one of the reasons why I questioned the need to store these strings in a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;: Good to see you again. :&lt;FONT face="helvetica"&gt;-&lt;/FONT&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 16:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/858977#M339399</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-02-15T16:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/859025#M339415</link>
      <description>&lt;P&gt;Macro variables are not meant to store&amp;nbsp;&lt;EM&gt;data&lt;/EM&gt;, but&amp;nbsp;&lt;EM&gt;pieces of code&lt;/EM&gt;. They are limited to 64k characters, so you cannot store 2000 UUIDs (each 36 characters) in one.&lt;/P&gt;
&lt;P&gt;How do those 2000 UUIDs arrive in your SAS environment?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 18:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/859025#M339415</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-15T18:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/859039#M339419</link>
      <description>&lt;PRE&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;%let x =%nrstr(f588c556-15c4-4d59-b9df-88b2c655a950,06d54597-fc35-459b-bc5e-1075e9643a1d,06d54597-fc35-459b-bc5e-2137e9643a1d);&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;data test  (keep =var1-var3);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt; string=symget('x');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;  count=countw(string, ',');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;  array myvars (3) $ 100 var1-var3;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;  do i=1 to dim(myvars);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;    myvars(i)=scan(string, i, ',');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;  end;&lt;/FONT&gt;&lt;BR /&gt; &lt;FONT face="lucida sans unicode,lucida sans"&gt;run;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 19:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/859039#M339419</guid>
      <dc:creator>Chabane_Haddad</dc:creator>
      <dc:date>2023-02-15T19:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/860157#M339826</link>
      <description>Thank for the info. Getting UUIDS from a different macro variable .</description>
      <pubDate>Wed, 22 Feb 2023 13:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/860157#M339826</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2023-02-22T13:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a macro variable value and convert it in  SAS data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/860367#M339889</link>
      <description>&lt;P&gt;A macro variable is already part of SAS. How does the data&amp;nbsp;&lt;U&gt;initially&lt;/U&gt; arrive in your SAS environment?&lt;/P&gt;
&lt;P&gt;And if the macro variable is filled from data out of a dataset, you can use the same step to create the code (statements are not limited in length), or use that extract in joins/hashes.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 06:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-macro-variable-value-and-convert-it-in-SAS-data/m-p/860367#M339889</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-23T06:39:33Z</dc:date>
    </item>
  </channel>
</rss>

