<?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: seach text file based on obs in data table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/seach-text-file-based-on-obs-in-data-table/m-p/394325#M94998</link>
    <description>&lt;P&gt;Hi Ballard,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much. Your data steps returns the correct 17 variables. &amp;nbsp; Sorry for any confusion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I justed wanted to read in that file and get the list of tables which are listed under "FILES" and then using those table names search the reset of the document for each table.variable combination.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So tab1 would be first and I want it to return the n variables that are associated with tab1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example it is these 3 like your code returns.&lt;/P&gt;
&lt;P&gt;tab1.id &amp;nbsp;&lt;BR /&gt;tab1.type&lt;BR /&gt;tab1.region&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again this is a big help.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2017 19:29:14 GMT</pubDate>
    <dc:creator>jerry898969</dc:creator>
    <dc:date>2017-09-08T19:29:14Z</dc:date>
    <item>
      <title>seach text file based on obs in data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seach-text-file-based-on-obs-in-data-table/m-p/394291#M94986</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a word document that is given to me that is a mock up of a project I'm going to work on.&amp;nbsp; What I want to do is take the list of tables at the start of the document and then scan the document and pull out and instance where the table.variable combination is listed so I can then create a process to check that these table.variable combinations exist before we start the project.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason is that the department we work with gives us mocks that don't match the meta data of their tables and we want to resolve it before we start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached is a test version of how the document will look.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data mock ;
	length text $400 ;
	infile '[path]\temp.txt' length = l ;
	input @1 text $varying400. l ;	
run ;

data tables (drop=flag) ;
	set mock ;
	retain flag ;

	if text = 'FILES:' then flag=1 ;
	if text = ' ' then flag=0 ;
	if text ne 'FILES:' and  flag=1 then output ;
run ;

data tables_ (keep=tabname) ;
	set tables ;
	tabname = scan(strip(text),1) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code will give me a table with a list of tables to search.&amp;nbsp; I need to have this list in the final table so I can loop through the dictionary.columns table making sure these variables exist in those tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;tab1.id  
tab1.type
tab1.region
tab2.ph1
tab2.Fore1
tab2.Ext1
tab3.ph2
tab3.Fore2
tab3.Ext2
tab4.ph3
tab4.Fore3
tab4.Ext3
tab5.name
tab5.co
tab5.addr
tab5.city
tab5.email&lt;/PRE&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 17:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seach-text-file-based-on-obs-in-data-table/m-p/394291#M94986</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2017-09-08T17:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: seach text file based on obs in data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seach-text-file-based-on-obs-in-data-table/m-p/394298#M94990</link>
      <description>&lt;P&gt;I am not quite sure I follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So is your question how to read that attached files to get the information that is follows the files in such a way that you can have the tab1.id and similar values? And then look those up in dictionary.columns?&lt;/P&gt;
&lt;P&gt;To search dictionary.columns we would need a library name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And does your actual source file have the line numbers preceeding?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This reads the data, gets the likely tablename.variable strings and parses out the memname(table) and name (variable).&lt;/P&gt;
&lt;PRE&gt;data possiblevars ;
	length text $400 ;
	infile datalines length = l ;
	input @1 text $varying400. l ;
   length str $ 42.;

   do i=1 to (countw(text,' :,'));
      str = scan(text,i,' :,');
      if index(str,'.')&amp;gt;0 then do;
         memname=upcase(scan(str,1,'.'));
         name = upcase(scan(str,2,'.'));
         output;
      end;
   end;
   drop i text;

datalines;
PROJECT TEST 1
FILES:
tab1
tab2
tab3
tab4
tab5

ID:  tab1.id  Type:  tab1.type   REGION:  tab1.region

Cell:  tab2.ph1  tab2.Fore1 tab2.Ext1
Home:  tab3.ph2  tab3.Fore2 tab3.Ext2
Other: tab4.ph3  tab4.Fore3 tab4.Ext3
tab5.name
tab5.co
tab5.addr
tab5.city
tab5.email 
;
run;




&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 18:17:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seach-text-file-based-on-obs-in-data-table/m-p/394298#M94990</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-08T18:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: seach text file based on obs in data table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seach-text-file-based-on-obs-in-data-table/m-p/394325#M94998</link>
      <description>&lt;P&gt;Hi Ballard,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much. Your data steps returns the correct 17 variables. &amp;nbsp; Sorry for any confusion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I justed wanted to read in that file and get the list of tables which are listed under "FILES" and then using those table names search the reset of the document for each table.variable combination.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So tab1 would be first and I want it to return the n variables that are associated with tab1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example it is these 3 like your code returns.&lt;/P&gt;
&lt;P&gt;tab1.id &amp;nbsp;&lt;BR /&gt;tab1.type&lt;BR /&gt;tab1.region&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again this is a big help.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 19:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seach-text-file-based-on-obs-in-data-table/m-p/394325#M94998</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2017-09-08T19:29:14Z</dc:date>
    </item>
  </channel>
</rss>

