<?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 list all variables in each set in a library and provide a sample in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491769#M129055</link>
    <description>&lt;P&gt;Another consideration in your "example values" display. Would you really want to display multiple values for a field that is basically open-ended text that runs 300+ characters long?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what about variable labels?&lt;/P&gt;</description>
    <pubDate>Fri, 31 Aug 2018 22:13:35 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-08-31T22:13:35Z</dc:date>
    <item>
      <title>How to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491554#M128937</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am a new user and I&amp;nbsp;need to specify my company's data base by listing all variables in each set in the library and provide a sample of the data existed in each variable (the best sample to provide is the most frequent one ) .&amp;nbsp;&lt;BR /&gt;Library&amp;nbsp;A&lt;/P&gt;
&lt;P&gt;Sets&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;- X&amp;nbsp; has&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 , 2, 3&lt;/P&gt;
&lt;P&gt;- Y&amp;nbsp; has&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 , 4 , 5&lt;/P&gt;
&lt;P&gt;and Z has&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 , 9 , 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used this&amp;nbsp;code so far , but I couldn't find out how to provide samples (using SQL) :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*List of variables in a library;


proc sql;
	create table columns as
		select libname ,
		       memname as table_name , 
		       name as variable

		from dictionary.columns
			where libname = 'A'
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please help me with that ?&lt;BR /&gt;Thanks and have a nice day. KR // Alaa&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 14:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491554#M128937</guid>
      <dc:creator>Zeitgeist69</dc:creator>
      <dc:date>2018-08-31T14:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Who to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491557#M128938</link>
      <description>&lt;P&gt;It might be that doing it manually will be quicker than creating the code for it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After finding all your variables, you have to:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;for each variable, concatenate the values from all datasets in which they appear. That requires identical attributes (type, length)&lt;/LI&gt;
&lt;LI&gt;run a proc freq on that, and select the top result&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;How many variables have you found in your library?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 08:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491557#M128938</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-31T08:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Who to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491558#M128939</link>
      <description>&lt;P&gt;Thanks for replay , The library i provided is just an example , I have actualy 10+ libraries each has 200+ data sets with&amp;nbsp;35+ variables each .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 08:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491558#M128939</guid>
      <dc:creator>Zeitgeist69</dc:creator>
      <dc:date>2018-08-31T08:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Who to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491565#M128943</link>
      <description>&lt;P&gt;As a new user, this is complicated programming, and as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has said, probably simpler to do it by hand.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From a purely programming aspect.&lt;/P&gt;
&lt;P&gt;Break it into two steps:&lt;/P&gt;
&lt;P&gt;1) Get list of all datasets/variables in the given libraries:&lt;/P&gt;
&lt;PRE&gt;data list;
  set sashelp.vcolumn;
  where libname in ("ABC","DEF");
run;
&lt;/PRE&gt;
&lt;P&gt;In this example I have libnames of abc and def.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Use this list to generate code for frequencies if character, means if numeric:&lt;/P&gt;
&lt;PRE&gt;proc sql;&lt;BR /&gt; create table freq_out (lib char(200),ds char(200),var char(200),value char(200),count num);&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt; set list;&lt;BR /&gt; if type="char" then do;&lt;BR /&gt;   call execute(cat('proc freq data=',catx('.',libname,memname),'; tables ',strip(name),' / out=tmp; run;'));&lt;BR /&gt;   call execute(cats('data tmp (keep=lib ds var value count); set tmp (rename=(',name,'=value)); length lib ds name var $200; lib="',libname,'"; ds="',memname,'"; var="',name,'"; run;'));&lt;BR /&gt;   call execute('proc append base=freq_out data=tmp force;run;');&lt;BR /&gt; end;&lt;BR /&gt; else do;&lt;BR /&gt;   /* Add code for proc means here */&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;This programs uses the list dataset to generate a proc freq for each variable (so will take a while to run), and then appends the output to a main dataset, thus building up frequency counts for character variables.&amp;nbsp; I haven't added the code for means as this is only a guide.&amp;nbsp; If you don't understand this type of coding, then I would just do it manually.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 08:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491565#M128943</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-31T08:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Who to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491569#M128946</link>
      <description>&lt;P&gt;Thanks , I will test it and will come with replay soon .&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 09:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491569#M128946</guid>
      <dc:creator>Zeitgeist69</dc:creator>
      <dc:date>2018-08-31T09:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Who to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491622#M128975</link>
      <description>&lt;P&gt;You can use SQL to&amp;nbsp;print samples like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Put the code you want to execute into a macro variable, and execute that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select catx(' ','Title "Sample of',memname,'";select * from',cats(libname,'.', memname,'(obs=10)'))
  into :sample separated by ';'
  from dictionary.tables
  where libname='A';
  &amp;amp;sample;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 13:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491622#M128975</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-08-31T13:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491740#M129037</link>
      <description>&lt;P&gt;For your first question, this is easy.&amp;nbsp; Assuming you have defined a libname called FOLDER1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc contents data=folder1._all_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Getting sample values for variables is much more complex.&amp;nbsp; What do you want to do with character variables?&amp;nbsp; Would an average value for numerics be more appropriate?&amp;nbsp; I think you need to investigate this a bit before trying a complex solution.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491740#M129037</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-31T20:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491769#M129055</link>
      <description>&lt;P&gt;Another consideration in your "example values" display. Would you really want to display multiple values for a field that is basically open-ended text that runs 300+ characters long?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what about variable labels?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 22:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/491769#M129055</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-31T22:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/492051#M129252</link>
      <description>&lt;P&gt;Hi , I need only one sample that presents the variable includings . and I thought the the most frequented one is the most efficient way.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 13:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/492051#M129252</guid>
      <dc:creator>Zeitgeist69</dc:creator>
      <dc:date>2018-09-03T13:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Who to list all variables in each set in a library and provide a sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/492052#M129253</link>
      <description>Thanks , but it displayed " No raws selected " note in the log.</description>
      <pubDate>Mon, 03 Sep 2018 13:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-list-all-variables-in-each-set-in-a-library-and-provide-a/m-p/492052#M129253</guid>
      <dc:creator>Zeitgeist69</dc:creator>
      <dc:date>2018-09-03T13:18:46Z</dc:date>
    </item>
  </channel>
</rss>

