<?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 finding specific values or string in a library with multiple datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/finding-specific-values-or-string-in-a-library-with-multiple/m-p/443943#M111102</link>
    <description>&lt;P&gt;SAS gurus,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I am trying to find accountno in a library with multiple datasets. I am unable to accomplish the task and I have put the code I used to build the logic.&amp;nbsp; Can someone please show me the direction?&lt;/P&gt;&lt;P&gt;1. i am getting all the accountno total in a macro as well accountno&lt;/P&gt;&lt;P&gt;2. get all the datasets I need to look into using dictionary.columns&lt;/P&gt;&lt;P&gt;3. use a macro to list individual dataset which contains either one or more accountno in them. If possible need to get all the accountno information (possibly using proc sql; select option instead of data _null_ in my code). I would like ideally to have the information of the dataset and all the observations pertaining to that accountno. I am failing in my third step. please help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*get the total number of accounts from kumngo and save them in a macro accountno*/&lt;BR /&gt;proc sql;&lt;BR /&gt;select count(distinct(accountno)) into :tot&lt;BR /&gt;from kumngo;&lt;BR /&gt;select distinct "'"||strip(accountno)|| "'" into :accountno&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;seperated by ","&lt;BR /&gt;from kumngo;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*Get all the the dataset names from datasets using dicitionary.columns*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT DISTINCT(MEMNAME), COUNT(DISTINCT(MEMNAME))&lt;BR /&gt;INTO :ds_list SEPARATED BY '~', :ds_cnt&lt;BR /&gt;FROM dictionary.columns&lt;BR /&gt;WHERE LIBNAME = 'DATASETS'&lt;BR /&gt;ORDER BY MEMNAME;&lt;BR /&gt;create table datasets as&lt;BR /&gt;select distinct (memname)&lt;BR /&gt;from dictionary.tables&lt;BR /&gt;where libname = 'DATASETS'&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*search individual dataset to find the accountno and list that dataset*/&lt;BR /&gt;%macro check;&lt;BR /&gt;%if &amp;amp;sqlobs ne 0 %then %do;&lt;BR /&gt;%DO I = 1 %TO &amp;amp;DS_CNT;&lt;BR /&gt;%LET DS = %SCAN (&amp;amp;DS_LIST., &amp;amp;I., ~);&lt;BR /&gt;data _null_;&lt;BR /&gt;set datasets.&amp;amp;DS. ;&lt;BR /&gt;if accountno in (&amp;amp;accountno) then put" accountnos are in &amp;amp;DS.";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%check ;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2018 01:10:45 GMT</pubDate>
    <dc:creator>buddha_d</dc:creator>
    <dc:date>2018-03-09T01:10:45Z</dc:date>
    <item>
      <title>finding specific values or string in a library with multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-specific-values-or-string-in-a-library-with-multiple/m-p/443943#M111102</link>
      <description>&lt;P&gt;SAS gurus,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I am trying to find accountno in a library with multiple datasets. I am unable to accomplish the task and I have put the code I used to build the logic.&amp;nbsp; Can someone please show me the direction?&lt;/P&gt;&lt;P&gt;1. i am getting all the accountno total in a macro as well accountno&lt;/P&gt;&lt;P&gt;2. get all the datasets I need to look into using dictionary.columns&lt;/P&gt;&lt;P&gt;3. use a macro to list individual dataset which contains either one or more accountno in them. If possible need to get all the accountno information (possibly using proc sql; select option instead of data _null_ in my code). I would like ideally to have the information of the dataset and all the observations pertaining to that accountno. I am failing in my third step. please help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*get the total number of accounts from kumngo and save them in a macro accountno*/&lt;BR /&gt;proc sql;&lt;BR /&gt;select count(distinct(accountno)) into :tot&lt;BR /&gt;from kumngo;&lt;BR /&gt;select distinct "'"||strip(accountno)|| "'" into :accountno&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;seperated by ","&lt;BR /&gt;from kumngo;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*Get all the the dataset names from datasets using dicitionary.columns*/&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT DISTINCT(MEMNAME), COUNT(DISTINCT(MEMNAME))&lt;BR /&gt;INTO :ds_list SEPARATED BY '~', :ds_cnt&lt;BR /&gt;FROM dictionary.columns&lt;BR /&gt;WHERE LIBNAME = 'DATASETS'&lt;BR /&gt;ORDER BY MEMNAME;&lt;BR /&gt;create table datasets as&lt;BR /&gt;select distinct (memname)&lt;BR /&gt;from dictionary.tables&lt;BR /&gt;where libname = 'DATASETS'&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*search individual dataset to find the accountno and list that dataset*/&lt;BR /&gt;%macro check;&lt;BR /&gt;%if &amp;amp;sqlobs ne 0 %then %do;&lt;BR /&gt;%DO I = 1 %TO &amp;amp;DS_CNT;&lt;BR /&gt;%LET DS = %SCAN (&amp;amp;DS_LIST., &amp;amp;I., ~);&lt;BR /&gt;data _null_;&lt;BR /&gt;set datasets.&amp;amp;DS. ;&lt;BR /&gt;if accountno in (&amp;amp;accountno) then put" accountnos are in &amp;amp;DS.";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%check ;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 01:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-specific-values-or-string-in-a-library-with-multiple/m-p/443943#M111102</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2018-03-09T01:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: finding specific values or string in a library with multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-specific-values-or-string-in-a-library-with-multiple/m-p/443971#M111108</link>
      <description>&lt;P&gt;Something like this would be a lot faster.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select 'DATASETS.'||MEMNAME into :dslist separated by ' '
  from DICTIONARY.TABLES
  where LIBNAME = 'DATASETS';
quit;

data WANT;
  set &amp;amp;dslist.(keep=ACCOUNTNO) indsname=_DS;
  where ACCOUNTNO in (&amp;amp;accountno.); 
  DSNAME=_DS;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please modify for your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 04:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-specific-values-or-string-in-a-library-with-multiple/m-p/443971#M111108</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-03-09T04:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: finding specific values or string in a library with multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-specific-values-or-string-in-a-library-with-multiple/m-p/443992#M111110</link>
      <description>&lt;P&gt;Thanks ChrisNZ. This seems to be the right solution. I would let you if I come across any problems. I didn't know indsname= option exists with set option.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 05:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-specific-values-or-string-in-a-library-with-multiple/m-p/443992#M111110</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2018-03-09T05:21:52Z</dc:date>
    </item>
  </channel>
</rss>

