<?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: Import all rows in one sas macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321422#M70971</link>
    <description>&lt;P&gt;Let SAS do all the work.&amp;nbsp; Use proc transpose:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc transpose data=have (keep=address) out=need;
  var address;
run;

data _null_;
  set need;
  call symput('ALLE',catx('!',of col:));
run;
%put &amp;amp;=alle;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CATX function separates each address by an "!".&amp;nbsp;&amp;nbsp; Ordinarily a "," is used, but that symbol is a part of the address value.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Dec 2016 13:23:07 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2016-12-28T13:23:07Z</dc:date>
    <item>
      <title>Import all rows in one sas macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321386#M70950</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am in limbo, trying to find an option which can read all the values of one column from a dataset and write all the values &amp;nbsp;in a macro variable, they should be in different lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HAVE: dataset named have with 5 records as below and column name addess as:&lt;/P&gt;
&lt;P&gt;1231, Gurgaon, INDIA&lt;/P&gt;
&lt;P&gt;142, TEXAS, US&lt;/P&gt;
&lt;P&gt;132,&amp;nbsp;Amsterdam, Netherland&lt;/P&gt;
&lt;P&gt;011, Zxurich, Switzerland&lt;/P&gt;
&lt;P&gt;123, Taj Mahal, Delhi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need:&lt;/P&gt;
&lt;P&gt;Macro variable named - ALLE having value as:&lt;/P&gt;
&lt;PRE&gt;%put &amp;amp;ALLE;&lt;/PRE&gt;
&lt;P&gt;output of %put should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1231, Gurgaon, INDIA
142, TEXAS, US
132,&amp;nbsp;Amsterdam, Netherland
011, Zxurich, Switzerland
123, Taj Mahal, Delhi&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is it possible, thanks in advance:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 06:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321386#M70950</guid>
      <dc:creator>mnjtrana</dc:creator>
      <dc:date>2016-12-28T06:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Import all rows in one sas macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321390#M70953</link>
      <description>&lt;P&gt;That seems like a weird functionality. Why not build macros that do a print?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 07:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321390#M70953</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-28T07:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Import all rows in one sas macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321395#M70956</link>
      <description>&lt;P&gt;I dont understand this. You want to write the values of just one column to a macro variable, but in your desires output from %PUT your have several columns? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 08:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321395#M70956</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-12-28T08:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Import all rows in one sas macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321396#M70957</link>
      <description>&lt;P&gt;I want to put all the values of one column- address for all the observations in one macro variable. the need is to have all these values in one macro variable(ALLE).&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 08:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321396#M70957</guid>
      <dc:creator>mnjtrana</dc:creator>
      <dc:date>2016-12-28T08:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Import all rows in one sas macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321410#M70964</link>
      <description>&lt;P&gt;Do you mean a program like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _NULL_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; length ALLE $1000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retain ALLE;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; infile &amp;nbsp;datalines;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input address $;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if _N_=1 then ALLE = address;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if substr(address,1,3)= 'ZZZ' then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;call symput('ALLE',strip allE);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&amp;nbsp;ALLE = catx(',', ALLE, address); /* you may change the delimiter from comma , to any other character */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* like: &amp;nbsp; catx(';' , ALLE, address) - using semicolon ; as delimiter */&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;1231, Gurgaon, INDIA&lt;/P&gt;
&lt;P&gt;142, TEXAS, US&lt;/P&gt;
&lt;P&gt;132,&amp;nbsp;Amsterdam, Netherland&lt;/P&gt;
&lt;P&gt;011, Zxurich, Switzerland&lt;/P&gt;
&lt;P&gt;123, Taj Mahal, Delhi&lt;/P&gt;
&lt;P&gt;ZZZ; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* line added to identify end of file */&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;%PUT ALLE = &amp;amp;alle;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 11:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321410#M70964</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-28T11:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Import all rows in one sas macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321422#M70971</link>
      <description>&lt;P&gt;Let SAS do all the work.&amp;nbsp; Use proc transpose:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc transpose data=have (keep=address) out=need;
  var address;
run;

data _null_;
  set need;
  call symput('ALLE',catx('!',of col:));
run;
%put &amp;amp;=alle;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CATX function separates each address by an "!".&amp;nbsp;&amp;nbsp; Ordinarily a "," is used, but that symbol is a part of the address value.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 13:23:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321422#M70971</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-28T13:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Import all rows in one sas macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321442#M70983</link>
      <description>&lt;P&gt;That is what the SEPARATED BY keyword in the INTO keyword in PROC SQL does. &amp;nbsp;You do need to think about what you want to use to separate the values. &amp;nbsp;Your output made it look like you want line breaks, but that concept doesn't really exist in a string value so you will need to pick a separator string based on how you plan to use the macro variable. Make sure to pick a character that cannot be in any particular address value. &amp;nbsp;Also make sure that your total string length will fit in the 64K maximum size of a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
  select address
    into :ALLE separated by '|'
    from have
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Dec 2016 16:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-all-rows-in-one-sas-macro-variable/m-p/321442#M70983</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-12-28T16:19:33Z</dc:date>
    </item>
  </channel>
</rss>

