<?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: Turn a list of value into file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715832#M221133</link>
    <description>&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;Thank you again for helping me out.&lt;/P&gt;
&lt;P&gt;It works perfectly.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
    <pubDate>Mon, 01 Feb 2021 17:23:02 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2021-02-01T17:23:02Z</dc:date>
    <item>
      <title>Turn a list of value into file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715705#M221092</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I have a list of value in the following format/statement:&lt;/P&gt;
&lt;P&gt;%LET list= a b c d e f g h e;&lt;/P&gt;
&lt;P&gt;a b c d e f g h e;&lt;/P&gt;
&lt;P&gt;I would like to use this list to create a dataset with a column containing these value.&lt;/P&gt;
&lt;P&gt;So the data should look like&lt;/P&gt;
&lt;P&gt;var&lt;/P&gt;
&lt;P&gt;a&lt;/P&gt;
&lt;P&gt;b&lt;/P&gt;
&lt;P&gt;c&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;e&lt;/P&gt;
&lt;P&gt;Can you please help me with that?&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 04:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715705#M221092</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2021-02-01T04:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Turn a list of value into file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715708#M221094</link>
      <description>&lt;P&gt;I think you may need PROC TRANSPOSE ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;DIV id="gtx-trans" style="position: absolute; left: -12px; top: 29.2118px;"&gt;
&lt;DIV class="gtx-trans-icon"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 01 Feb 2021 05:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715708#M221094</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-01T05:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Turn a list of value into file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715713#M221095</link>
      <description>&lt;P&gt;So you have a macro variable with a space delimited list of words and you want to convert it into a dataset? So it this example the macro variable is name LIST.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET list= a b c d e f g h e;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You haven't said what dataset you want to create or what name you want to use for the variable to hold the words.&lt;/P&gt;
&lt;P&gt;So let's make a dataset named WANT and use WORD as the name of the variable.&lt;/P&gt;
&lt;P&gt;You also did not say the maximum number of characters that any word could contain. Let's just assume that is 8.&lt;/P&gt;
&lt;P&gt;So a simple DO loop should do the trick.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  length word $8 ;
  do index=1 to countw("&amp;amp;list",' ');
    word = scan("&amp;amp;list",index,' ');
    output;
  end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Feb 2021 06:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715713#M221095</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-01T06:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Turn a list of value into file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715719#M221097</link>
      <description>&lt;P&gt;I would like to go some steps backwards: why do have a list of values in a macro-variable? Is this a homework-task or a real-life problem? If it is the later, than it is most likely possible to create the required dataset without the detour using a macro-variable.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 06:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715719#M221097</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-01T06:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Turn a list of value into file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715832#M221133</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;Thank you again for helping me out.&lt;/P&gt;
&lt;P&gt;It works perfectly.&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 17:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715832#M221133</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2021-02-01T17:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Turn a list of value into file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715844#M221138</link>
      <description>&lt;P&gt;Note that if the list is comma separated you can use it directly in the DO statement without the need for INDEX or SCAN().&lt;/P&gt;
&lt;P&gt;So for numeric values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=1,2,3,4,5;
data want;
  do value=&amp;amp;list;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And for character variable include the quotes in the macro variable LIST.&amp;nbsp; Note it is best to define the length of the variable first otherwise SAS will guess a length based on the first value in the list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list='a',"b",'c' ;
data want;
  length value $8;
  do value=&amp;amp;list;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Feb 2021 18:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turn-a-list-of-value-into-file/m-p/715844#M221138</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-01T18:06:31Z</dc:date>
    </item>
  </channel>
</rss>

