<?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: Select many variabled in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451550#M113867</link>
    <description>&lt;P&gt;Someone posted this yesterday, it may be helpful to you:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Macro-to-Generate-List-of-Variables-with-Suffix/m-p/451323" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Macro-to-Generate-List-of-Variables-with-Suffix/m-p/451323&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 15:02:13 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-04-05T15:02:13Z</dc:date>
    <item>
      <title>Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451429#M113798</link>
      <description>&lt;P&gt;How select all variables which have same end,&amp;nbsp;&lt;/P&gt;&lt;P&gt;ex. aeSAF1 beSAF1 ceSAF1 i need to select all&amp;nbsp;variables &amp;nbsp;ending with SAF1&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 09:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451429#M113798</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2018-04-05T09:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451432#M113799</link>
      <description>&lt;P&gt;In what sense?&amp;nbsp; I.e. do you mean in an sql select, a keep statement, in an array?&amp;nbsp; In datastep you can use the : to indicate all with prefix of and numeric suffix, e.g.:&lt;/P&gt;
&lt;PRE&gt;test=sum(of aesaf:);&lt;/PRE&gt;
&lt;P&gt;Assuming all the variables are numeric, have the prefix of aesaf, and then have a number after, like: aesaf1, aesaf2 etc.&lt;/P&gt;
&lt;P&gt;You can also use ranges:&lt;/P&gt;
&lt;PRE&gt;test=sum(of aesaf1--aesaf10);&lt;/PRE&gt;
&lt;P&gt;To indicate all variables which logically appear between aesaf1 and aesaf10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Context is everything in questions, follow the guidance, post test data in the form of a datastep, show what you want out at the end etc.&amp;nbsp; Its hard to suggest anything with no information to go on.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451432#M113799</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-05T10:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451433#M113800</link>
      <description>my example bellow&lt;BR /&gt;aSAF1 bSAF1 cSAF1 eSAF1 i need to select when SAF1 in the end</description>
      <pubDate>Thu, 05 Apr 2018 10:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451433#M113800</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2018-04-05T10:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451434#M113801</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
    set have;

    call execute('data want; set have; keep');

    do while (varname ne "varname");
        call vnext(varname);
        suffix=substr(varname,length(varname)-3);
        if suffix="SAF1" then do;
            call execute(varname);
        end;
    end;

    call execute('; run;');
    stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451434#M113801</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-04-05T10:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451436#M113803</link>
      <description>&lt;P&gt;This does not tell me anything.&amp;nbsp; Please review the guidance for posting a new question - post test data in the form of a datastep, what the output should look like.&amp;nbsp; What you have written, what logs etc.&amp;nbsp; The term select is vague.&amp;nbsp; Let me explain:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example question:&lt;/P&gt;
&lt;P&gt;I have a dataset which looks like:&lt;/P&gt;
&lt;PRE&gt;data have;
  infile datalines;
  input aesaf1 aesaf2 aesaf3;
datalines;
1 2 3
;
run;&lt;/PRE&gt;
&lt;P&gt;I need to sum these variables into a new variable called result.&amp;nbsp; My output should look like:&lt;/P&gt;
&lt;P&gt;aesaf1&amp;nbsp; aesaf2&amp;nbsp; aesaf3&amp;nbsp; result&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Response:&lt;/P&gt;
&lt;P&gt;Here is code which does what you ask;&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  result=sum(of aesaf:);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, if you want to keep only those variables mentioned then:&lt;/P&gt;
&lt;PRE&gt;data want (keep=asaf1--esaf1);
  set have;
run;&lt;/PRE&gt;
&lt;P&gt;You could transpose the dataset (assuming that the variables are the same) - this would be ideal as working with normalised (goes down rather than across) is far far easier and avoids problems like this that your facing.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451436#M113803</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-05T10:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451437#M113804</link>
      <description>&lt;P&gt;you give me simple one with numeric end,that was very simple we can use like a1-a10 or... I need what I write in comment with same end part . Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451437#M113804</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2018-04-05T10:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451441#M113806</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100963"&gt;@Vahe_Mar&lt;/a&gt; wrote:&lt;BR /&gt;my example bellow&lt;BR /&gt;aSAF1 bSAF1 cSAF1 eSAF1 i need to select when SAF1 in the end&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unfortunately there is no easy way to do this.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451441#M113806</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-04-05T10:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451442#M113807</link>
      <description>&lt;P&gt;Having the dynamic part of the variable names in front instead of at the end is of course suboptimal, as it precludes the use of the : wildcard that SAS provides.&lt;/P&gt;
&lt;P&gt;You will be forced to read variable names from dictionary.columns with a contains condition or similar, and put them into a macro variable with the into: clause:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :varlist separated by " "
from dictionary.columns
where libname = 'LIBRARY' and memname = 'DATASET' and name contains 'SAF1';
quit;

proc print data=library.dataset;
var &amp;amp;varlist;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451442#M113807</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-05T10:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451443#M113808</link>
      <description>Thanks, that is right decision , but data in work and in sas help only present datas from data</description>
      <pubDate>Thu, 05 Apr 2018 10:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451443#M113808</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2018-04-05T10:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451446#M113811</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100963"&gt;@Vahe_Mar&lt;/a&gt; wrote:&lt;BR /&gt;Thanks, that is right decision , but data in work and in sas help only present datas from data&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no clue what you mean.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451446#M113811</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-05T10:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451447#M113812</link>
      <description>I tried to use that sql , with data from sashelp which contains variable name information, but in that library only contains data from "data" library not from work</description>
      <pubDate>Thu, 05 Apr 2018 10:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451447#M113812</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2018-04-05T10:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451449#M113814</link>
      <description>&lt;P&gt;Post your code, please.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451449#M113814</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-05T10:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451540#M113860</link>
      <description>&lt;P&gt;SAS doesn't work well with suffixes unfortunately.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any control over the naming structure use a prefix method instead and then you can shortcut list them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL does not support variables lists at all though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/100963"&gt;@Vahe_Mar&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;How select all variables which have same end,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ex. aeSAF1 beSAF1 ceSAF1 i need to select all&amp;nbsp;variables &amp;nbsp;ending with SAF1&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 14:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451540#M113860</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-05T14:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select many variabled</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451550#M113867</link>
      <description>&lt;P&gt;Someone posted this yesterday, it may be helpful to you:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Macro-to-Generate-List-of-Variables-with-Suffix/m-p/451323" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Macro-to-Generate-List-of-Variables-with-Suffix/m-p/451323&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 15:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-many-variabled/m-p/451550#M113867</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-05T15:02:13Z</dc:date>
    </item>
  </channel>
</rss>

