<?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 printing data set in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9234#M596</link>
    <description>I want to print variables which contains "samp" is variable name.&lt;BR /&gt;
&lt;BR /&gt;
example :&lt;BR /&gt;
data abc ;&lt;BR /&gt;
input a1 a3 za ba ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 2 3 4&lt;BR /&gt;
4 5 6 7&lt;BR /&gt;
7 8 9 0&lt;BR /&gt;
;&lt;BR /&gt;
proc print data=abc;&lt;BR /&gt;
var a:;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The above data print all the variables which is starting with A;&lt;BR /&gt;
&lt;BR /&gt;
in my data set contains some of the variables jan_samp1, feb_samp2 like that.&lt;BR /&gt;
i want to print the variables which contains "samp" in that variable name.</description>
    <pubDate>Mon, 23 Mar 2009 05:09:39 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-03-23T05:09:39Z</dc:date>
    <item>
      <title>printing data set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9234#M596</link>
      <description>I want to print variables which contains "samp" is variable name.&lt;BR /&gt;
&lt;BR /&gt;
example :&lt;BR /&gt;
data abc ;&lt;BR /&gt;
input a1 a3 za ba ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 2 3 4&lt;BR /&gt;
4 5 6 7&lt;BR /&gt;
7 8 9 0&lt;BR /&gt;
;&lt;BR /&gt;
proc print data=abc;&lt;BR /&gt;
var a:;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The above data print all the variables which is starting with A;&lt;BR /&gt;
&lt;BR /&gt;
in my data set contains some of the variables jan_samp1, feb_samp2 like that.&lt;BR /&gt;
i want to print the variables which contains "samp" in that variable name.</description>
      <pubDate>Mon, 23 Mar 2009 05:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9234#M596</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-23T05:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: printing data set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9235#M597</link>
      <description>Hello Sairam,&lt;BR /&gt;
&lt;BR /&gt;
Use Keep Option and print required variables.</description>
      <pubDate>Mon, 23 Mar 2009 09:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9235#M597</guid>
      <dc:creator>venkatesh</dc:creator>
      <dc:date>2009-03-23T09:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: printing data set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9236#M598</link>
      <description>Hi I Have data set like:&lt;BR /&gt;
&lt;BR /&gt;
Data jan;&lt;BR /&gt;
input a b a_samp b_samp c_samp d_samp c d e;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 2 3 4 5 6 7 8 9&lt;BR /&gt;
4 5 6 7 8 9 0 1 2&lt;BR /&gt;
;&lt;BR /&gt;
 &lt;BR /&gt;
i want to print the variables which contains "samp" as variable names &lt;BR /&gt;
ex:   a_samp , b_samp ,  c_samp , d_samp   only from the above data set.&lt;BR /&gt;
&lt;BR /&gt;
if i use the following code :&lt;BR /&gt;
proc print data=jan;&lt;BR /&gt;
var a:;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
the output is;&lt;BR /&gt;
&lt;BR /&gt;
a a_samp&lt;BR /&gt;
1 3&lt;BR /&gt;
4 6&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
i want a code like above my out put willl be:&lt;BR /&gt;
&lt;BR /&gt;
a_samp b_samp c_samp d_samp &lt;BR /&gt;
&lt;BR /&gt;
 3             4          5              6 &lt;BR /&gt;
 6             7          8              9 &lt;BR /&gt;
;</description>
      <pubDate>Mon, 23 Mar 2009 10:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9236#M598</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-23T10:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: printing data set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9237#M599</link>
      <description>Hi Sairam,&lt;BR /&gt;
&lt;BR /&gt;
There is no simple solution to this, well nothing a simple as a wildcard like colon. There are solutions. They would involve macro language. There are various ways to find out what variables are in your dataset but the use of dictionary tables here would be my choice. Using SQL to create a macro variable containg the names of the variables you want to keep.&lt;BR /&gt;
&lt;BR /&gt;
Here is the code I would use:&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
select lowcase(name) into: keep_vars &lt;BR /&gt;
from dictionary.columns&lt;BR /&gt;
where upcase(memname)="JAN" and upcase(libname)="WORK" and substr(reverse(upcase(name)),1,5)="PMAS_";&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
then you can use the keep_vars macro variable in your code to select the variables you want. For example:&lt;BR /&gt;
&lt;BR /&gt;
proc print data=jan;&lt;BR /&gt;
var &amp;amp;keep_vars;&lt;BR /&gt;
run;</description>
      <pubDate>Mon, 23 Mar 2009 11:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9237#M599</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-23T11:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: printing data set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9238#M600</link>
      <description>Unfortunatly the : only works at the end of a name to to create a SAS Variable List with all names beginning with a character string.  To create the list you desire with SAMP at the end you need to use the meta data assocaited with the table.  One way that is common uses DICTIONARY.TABLES and the WHERE clause LIKE operator.  This example creates a macro variable that can be used later in a VAR statement perhaps.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Data jan;&lt;BR /&gt;
   input a b a_samp b_samp c_samp d_samp c d e;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
1 2 3 4 5 6 7 8 9&lt;BR /&gt;
4 5 6 7 8 9 0 1 2&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select name into :names separated ' '&lt;BR /&gt;
   from dictionary.columns&lt;BR /&gt;
   where &lt;BR /&gt;
      libname eq 'WORK' and memname eq 'JAN'&lt;BR /&gt;
      and upcase(name) like '%SAMP'&lt;BR /&gt;
      ;&lt;BR /&gt;
   quit;&lt;BR /&gt;
   run;&lt;BR /&gt;
%put NOTE: NAMES=&amp;amp;names;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 23 Mar 2009 11:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/printing-data-set/m-p/9238#M600</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-03-23T11:27:18Z</dc:date>
    </item>
  </channel>
</rss>

