<?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: Look up in loops / can not add in the additional path to look up for more data in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371942#M11281</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Below is initial code where lookup pulls cases from the &amp;amp;ac list of diagnosis. Attached in notepad is hardcode only for 2016 and 2017. In this case i have more than 3 years so would be tedious and exhausting. I thought of making type a parameter but i was afraid to distort the standard look up code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data icd(drop=icd10 rename=x=icd); set icd;
  icd_10_original=icd10;
 x="[*]"||icd10; run;

proc sql noprint;
   select  icd
     into :ac separated by '|'
     from  icd;
quit;

%put &amp;amp;ac;

options compress=yes;
%let x=:Code_1 - :Code_24;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hh&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jun 2017 00:31:43 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2017-06-30T00:31:43Z</dc:date>
    <item>
      <title>Look up in loops / can not add in the additional path to look up for more data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371934#M11279</link>
      <description>&lt;P&gt;My data is labeled after year created and saved in two separate folders with path "..\out" and "....\out\recent" (defined better below). I have no privilige to move files even though I tried to put all data in the same folder. Current look up works for data after 2016. But I need to use earlier data as well. &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to achieve is&amp;nbsp;to direct the loop to pull out data from "libname...\Out" &amp;nbsp;if data is before 2015, else pull out from "libname...Out\recent" if data is after 2016.&lt;/P&gt;&lt;P&gt;I simply added below chunk in the code in the box with no success. Log is "NOTE: The data set WORK.ALL_OUT_OTHER has 0 observations and 11 variables". How is it possible? Macro as is before I add another libname returns about&amp;nbsp;200 cases from&amp;nbsp;&lt;SPAN&gt;"libname...Out\recent". But no observations after additional path is added in to look up for more data? Using 9.4.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if &amp;amp;year &amp;lt;= 2015 %then&lt;BR /&gt;%do;&lt;BR /&gt;libname read_in "C:\Data\SPARCSdeidentified\&amp;amp;type";&lt;/P&gt;&lt;P&gt;%if &amp;amp;type=Int %then %let file=&amp;amp;type._s_;&lt;BR /&gt;%else;&lt;BR /&gt;%if &amp;amp;type=Out %then %let file=&amp;amp;type._s_p_;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname read_in "C:\Data\SPARCSdeidentified\Int";
libname read_op "C:\Data\SPARCSdeidentified\Out\recent";

%macro loop(case);

%global case1;
%let case1=&amp;amp;case;

%if &amp;amp;case=diseases                        %then %let condition = &amp;amp;ac;

proc datasets noprint;
 delete all_&amp;amp;type._other;
run;
 
%do year = 2015 %to 2017; 
%if &amp;amp;year &amp;gt;= 2016 %then 
  %do; 
    libname read_in "C:\Data\SPARCSdeidentified\&amp;amp;type\recent";
     %if &amp;amp;type=Int %then %let file=&amp;amp;type._s_;
	  %else;
     %if &amp;amp;type=Out %then %let file=&amp;amp;type._s_p_;
   %end; 

data temp(compress=yes); set read_in.&amp;amp;file&amp;amp;year;
icd_code = catx('*','*',Code, of Other_Code:); 

if prxmatch("m/&amp;amp;condition/oi",icd_code) &amp;gt; 0; 
source="Int";
run;

proc append base=all_&amp;amp;type._other(compress=yes) data=temp force;
run;

%end;

%mend loop;

%let type=Int;
%loop(diseases);

%let type=Out;
%loop(Other);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2017 23:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371934#M11279</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-29T23:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Look up in loops / can not add in the additional path to look up for more data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371940#M11280</link>
      <description>&lt;P&gt;Why not make the libname the IF condition. Then you can use the same code for the test of the stuff.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, why not make Type a parameter in your macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does your hardcoded working code look like?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 00:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371940#M11280</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-30T00:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Look up in loops / can not add in the additional path to look up for more data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371942#M11281</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Below is initial code where lookup pulls cases from the &amp;amp;ac list of diagnosis. Attached in notepad is hardcode only for 2016 and 2017. In this case i have more than 3 years so would be tedious and exhausting. I thought of making type a parameter but i was afraid to distort the standard look up code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data icd(drop=icd10 rename=x=icd); set icd;
  icd_10_original=icd10;
 x="[*]"||icd10; run;

proc sql noprint;
   select  icd
     into :ac separated by '|'
     from  icd;
quit;

%put &amp;amp;ac;

options compress=yes;
%let x=:Code_1 - :Code_24;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hh&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 00:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371942#M11281</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T00:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Look up in loops / can not add in the additional path to look up for more data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371943#M11282</link>
      <description>hard to make type a parameter because I have two solutions for type after different folders in the path such as Int and Out</description>
      <pubDate>Fri, 30 Jun 2017 00:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371943#M11282</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T00:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Look up in loops / can not add in the additional path to look up for more data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371950#M11283</link>
      <description>&lt;P&gt;I just put all my data together in the same folder. Just run below and still got no observations in final output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do year = 2015 %to 2017; 
 %do; 
    libname read_in "D:\data\&amp;amp;type";
     %if &amp;amp;type=Int %then %let file=&amp;amp;type._s_;
	  %else;
     %if &amp;amp;type=Out %then %let file=&amp;amp;type._s_prime_;
   %end; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Log says:&lt;/P&gt;&lt;P&gt;NOTE: The file WORK.ALL_OUT_OTHER (memtype=DATA) was not found, but appears on a DELETE&lt;BR /&gt;statement.&lt;BR /&gt;NOTE: Libref READ_IN was successfully assigned as follows:&lt;BR /&gt;Engine: V9&lt;BR /&gt;Physical Name: D:\\Out&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE DATASETS used (Total process time):&lt;BR /&gt;real time 1.44 seconds&lt;BR /&gt;cpu time 0.34 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: There were 67986 observations read from the data set READ_IN.OUT_2015.&lt;BR /&gt;WHERE (patient_state='NY') and ('2015'&amp;lt;=SUBSTR(LEFT(patient_birth_date), 1, 4)) and&lt;BR /&gt;patient_county_code in (2, 4, 6, 14, 18, 26, 29, 33, 34, 37, 39, 55, 56, 58) and&lt;BR /&gt;(SUBSTR(LEFT(patient_birth_date), 1, 4)&amp;lt;='2017');&lt;BR /&gt;NOTE: The data set WORK.TEMP has 0 observations and 11 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 1:57.57&lt;BR /&gt;cpu time 34.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Appending WORK.TEMP to WORK.ALL_OUT_OTHER.&lt;BR /&gt;NOTE: BASE data set does not exist. DATA file is being copied to BASE file.&lt;BR /&gt;NOTE: There were 0 observations read from the data set WORK.TEMP.&lt;BR /&gt;NOTE: The data set WORK.ALL_OUT_OTHER has 0 observations and 11 variables.&lt;BR /&gt;NOTE: PROCEDURE APPEND used (Total process time):&lt;BR /&gt;real time 0.06 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Libref READ_IN was successfully assigned as follows:&lt;BR /&gt;Engine: V9&lt;BR /&gt;Physical Name: D:\..\Out&lt;BR /&gt;WARNING: Apparent symbolic reference CONDITION not resolved.&lt;/P&gt;&lt;P&gt;NOTE: There were 184448 observations read from the data set READ_IN.OUT_2016.&lt;BR /&gt;WHERE (patient_state='NY') and ('2015'&amp;lt;=SUBSTR(LEFT(patient_birth_date), 1, 4)) and&lt;BR /&gt;patient_county_code in (2, 4, 6, 14, 18, 26, 29, 33, 34, 37, 39, 55, 56, 58) and&lt;BR /&gt;(SUBSTR(LEFT(patient_birth_date), 1, 4)&amp;lt;='2017');&lt;BR /&gt;NOTE: The data set WORK.TEMP has 0 observations and 11 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 2:33.67&lt;BR /&gt;cpu time 46.76 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Appending WORK.TEMP to WORK.ALL_OUT_OTHER.&lt;BR /&gt;NOTE: There were 0 observations read from the data set WORK.TEMP.&lt;BR /&gt;NOTE: 0 observations added.&lt;BR /&gt;NOTE: The data set WORK.ALL_OUT_OTHER has 0 observations and 11 variables.&lt;BR /&gt;NOTE: PROCEDURE APPEND used (Total process time):&lt;BR /&gt;real time 0.04 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Libref READ_IN was successfully assigned as follows:&lt;BR /&gt;Engine: V9&lt;BR /&gt;Physical Name: D:\sparcsdoh\task3\task3data\SPARCSdeidentified\Outpatient&lt;BR /&gt;WARNING: Apparent symbolic reference CONDITION not resolved.&lt;/P&gt;&lt;P&gt;NOTE: There were 64071 observations read from the data set READ_IN.OUT_S_PRIME_2017.&lt;BR /&gt;WHERE (patient_state='NY') and ('2015'&amp;lt;=SUBSTR(LEFT(patient_birth_date), 1, 4)) and&lt;BR /&gt;patient_county_code in (2, 4, 6, 14, 18, 26, 29, 33, 34, 37, 39, 55, 56, 58) and&lt;BR /&gt;(SUBSTR(LEFT(patient_birth_date), 1, 4)&amp;lt;='2017');&lt;BR /&gt;NOTE: The data set WORK.TEMP has 0 observations and 11 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 39.43 seconds&lt;BR /&gt;cpu time 9.90 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Appending WORK.TEMP to WORK.ALL_OUT_OTHER.&lt;BR /&gt;NOTE: There were 0 observations read from the data set WORK.TEMP.&lt;BR /&gt;NOTE: 0 observations added.&lt;BR /&gt;NOTE: The data set WORK.ALL_OUT_OTHER has 0 observations and 11 variables.&lt;BR /&gt;NOTE: PROCEDURE APPEND used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea? Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2017 01:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/371950#M11283</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-06-30T01:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Look up in loops / can not add in the additional path to look up for more data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/372007#M11285</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I believe for your latest issue the Condition doesn't work.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;WARNING: Apparent symbolic reference CONDITION not resolved.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For accessing tables from different folders:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can define a single libref for multiple paths/folders (concatenated library). As long as the tables in the folders have different names you then can access these tables as if they would reside in a single folder.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If your tables follow a naming convention then you can read them using the column modifier.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Code sample:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname source ('c:\temp', 'c:\test');

data want;
  length _intbl sourceTable $32;
  set source.OUT_20: indsname=_intbl;
  sourceTable=_intbl;
run;
  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Jun 2017 06:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Look-up-in-loops-can-not-add-in-the-additional-path-to-look-up/m-p/372007#M11285</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-06-30T06:06:45Z</dc:date>
    </item>
  </channel>
</rss>

