<?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: Proc summary: give a list of variables to var in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-give-a-list-of-variables-to-var/m-p/890168#M39588</link>
    <description>&lt;P&gt;There is no short way of specifying variables with a common suffix.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do something like this, put them in a macro vairable and use that in your Proc Summary&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID One_0 SecondVar Two_0 One Three_0 Three;
datalines;
1 1 2 3 1 2 3
2 4 5 6 4 5 6
3 7 8 9 7 8 9
4 1 2 3 1 2 3
5 4 5 6 4 5 6
;

%let suffix=_0;
 
proc sql noprint;
   select name into :vars separated by ' ' 
   from dictionary.columns 
   where upcase(libname)=upcase('work') 
     and upcase(memname)=upcase('have')
     and upcase(substr(name,length(name)-(length("&amp;amp;suffix")-1),length("&amp;amp;suffix")))=upcase("&amp;amp;suffix");
quit;
 
%put &amp;amp;vars;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Aug 2023 10:30:19 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2023-08-21T10:30:19Z</dc:date>
    <item>
      <title>Proc summary: give a list of variables to var</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-give-a-list-of-variables-to-var/m-p/890167#M39587</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to do a proc summary and you have a list of variables ending with "_0" you want to give to var. How can you indicate all that variables at once? They are not in a specified order to use "fromthefirst--tothelast".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 10:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-give-a-list-of-variables-to-var/m-p/890167#M39587</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-21T10:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary: give a list of variables to var</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-give-a-list-of-variables-to-var/m-p/890168#M39588</link>
      <description>&lt;P&gt;There is no short way of specifying variables with a common suffix.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do something like this, put them in a macro vairable and use that in your Proc Summary&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID One_0 SecondVar Two_0 One Three_0 Three;
datalines;
1 1 2 3 1 2 3
2 4 5 6 4 5 6
3 7 8 9 7 8 9
4 1 2 3 1 2 3
5 4 5 6 4 5 6
;

%let suffix=_0;
 
proc sql noprint;
   select name into :vars separated by ' ' 
   from dictionary.columns 
   where upcase(libname)=upcase('work') 
     and upcase(memname)=upcase('have')
     and upcase(substr(name,length(name)-(length("&amp;amp;suffix")-1),length("&amp;amp;suffix")))=upcase("&amp;amp;suffix");
quit;
 
%put &amp;amp;vars;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Aug 2023 10:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-give-a-list-of-variables-to-var/m-p/890168#M39588</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-08-21T10:30:19Z</dc:date>
    </item>
  </channel>
</rss>

