<?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 use retain and list the columns from another table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831613#M328638</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :names separated by " "
from dictionary.columns
where libname = "LIBNAME" and memname = "DSNAME"
order by name;
quit;

data want;
retain &amp;amp;names.;
set libname.dsname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Sep 2022 19:40:04 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-09-02T19:40:04Z</dc:date>
    <item>
      <title>How to use retain and list the columns from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831608#M328636</link>
      <description>&lt;P&gt;I want to retain column names in the alphabetical order. I already have another table which has a single column consisting of these names in alphabetical order. Can I somehow incorporate this into the retain statement instead of typing all the column names manually?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 19:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831608#M328636</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2022-09-02T19:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use retain and list the columns from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831613#M328638</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :names separated by " "
from dictionary.columns
where libname = "LIBNAME" and memname = "DSNAME"
order by name;
quit;

data want;
retain &amp;amp;names.;
set libname.dsname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Sep 2022 19:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831613#M328638</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-09-02T19:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use retain and list the columns from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831659#M328673</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I already have another table which has a single column consisting of these names in alphabetical order. Can I somehow incorporate this into the retain statement instead of typing all the column names manually?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, in &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_blank" rel="noopener"&gt;Kurt_Bremser&lt;/A&gt;'s code replace&lt;/P&gt;
&lt;PRE&gt;dictionary.columns
where libname = "LIBNAME" and memname = "DSNAME"&lt;/PRE&gt;
&lt;P&gt;with the name of that other table and replace "&lt;FONT face="courier new,courier"&gt;name&lt;/FONT&gt;" with the name of its single column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you could use CALL SYMPUTX in a data step to write the variable names from that table (concatenated with the CATX function) into macro variable &lt;FONT face="courier new,courier"&gt;names&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 13:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831659#M328673</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-09-03T13:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to use retain and list the columns from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831933#M328820</link>
      <description>&lt;P&gt;I'm getting an error for each column saying:&lt;/P&gt;
&lt;P&gt;ERROR: Alphabetic prefixes for enumerated variables (&amp;lt;column name&amp;gt;) are different.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 13:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831933#M328820</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2022-09-06T13:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use retain and list the columns from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831938#M328822</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm getting an error for each column saying:&lt;/P&gt;
&lt;P&gt;ERROR: Alphabetic prefixes for enumerated variables (&amp;lt;column name&amp;gt;) are different.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is how SAS punishes people who insist on using non-standard variable names. ;&lt;FONT face="helvetica"&gt;-&lt;/FONT&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p08pv65zqs289nn1rhylzpn95q71.htm" target="_blank" rel="noopener"&gt;NLITERAL function&lt;/A&gt; should resolve the issue, though:&lt;/P&gt;
&lt;PRE&gt;select &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;nliteral(&lt;/STRONG&gt;&lt;/FONT&gt;name&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt; into :names separated by " "&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Sep 2022 13:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831938#M328822</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-09-06T13:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use retain and list the columns from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831946#M328826</link>
      <description>haha that worked, thank you so much!</description>
      <pubDate>Tue, 06 Sep 2022 14:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-retain-and-list-the-columns-from-another-table/m-p/831946#M328826</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2022-09-06T14:09:50Z</dc:date>
    </item>
  </channel>
</rss>

