<?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: search a specific library if they have specific datsets with required variables then append them in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303942#M64646</link>
    <description>&lt;P&gt;Copy and paste your code to a clean editor, removing the %macro and %mend portion. Replace every macro variable with the parameter you pass in, literally copy and paste, and you'll see your mistake.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't, try and run it and see your errors.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is repitive so so you only need to do this for one PROC SQL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Or check it against here, since I'm assuming this is the same person.&amp;nbsp;&lt;A href="http://stackoverflow.com/q/39872795/1919583" target="_blank"&gt;http://stackoverflow.com/q/39872795/1919583&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You didn't copy and paste correctly....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Poece of advice - I think this is probably your fourth question/thread on this topic at least. It's better to keep your question to one thread/question and then you can build on the answer and get help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Oct 2016 05:47:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-10-12T05:47:17Z</dc:date>
    <item>
      <title>search a specific library if they have specific datsets with required variables then append them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303940#M64645</link>
      <description>&lt;P&gt;my code checks the datasets in a library if they have the required variables then append them.&lt;/P&gt;
&lt;P&gt;below is my code ----&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro chkvar(lib1=,lib2=,varlist=);&lt;/P&gt;
&lt;P&gt;%local&lt;BR /&gt;list&lt;BR /&gt;ds&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt; select distinct catx(".",libname,memname) into :list separated by " "&lt;BR /&gt; from dictionary.columns&lt;BR /&gt; where libname = %upcase ("&amp;amp;lib1") and %upcase(name) in("&amp;amp;varlist") ;&lt;BR /&gt; quit;&lt;BR /&gt;%put &amp;amp;list;&lt;/P&gt;
&lt;P&gt;data test1;&lt;BR /&gt; set &amp;amp;list;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt; select distinct catx(".",libname,memname) into :ds separated by " "&lt;BR /&gt; from dictionary.columns&lt;BR /&gt; where libname = %upcase ("&amp;amp;lib2") and %upcase(name) in("&amp;amp;varlist") ;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;ds;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt; set &amp;amp;ds;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;%mend CHK;&lt;/P&gt;
&lt;P&gt;%chkvar(lib1=detail,lib2=stats,varlist=%str('nam', 'DD', 'ht'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but some how the code returns error of symbolic refrence to &amp;amp;list and &amp;amp;ds not found and also doedn't check the given library at all for the data-sets which hav the variables. ihave created 2 separate librarys 'detail' and 'stats' with the variables still it doesn't do the intented task.. can u suggest in any edit to rectify my code...&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 05:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303940#M64645</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-10-12T05:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: search a specific library if they have specific datsets with required variables then append them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303942#M64646</link>
      <description>&lt;P&gt;Copy and paste your code to a clean editor, removing the %macro and %mend portion. Replace every macro variable with the parameter you pass in, literally copy and paste, and you'll see your mistake.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't, try and run it and see your errors.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is repitive so so you only need to do this for one PROC SQL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Or check it against here, since I'm assuming this is the same person.&amp;nbsp;&lt;A href="http://stackoverflow.com/q/39872795/1919583" target="_blank"&gt;http://stackoverflow.com/q/39872795/1919583&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You didn't copy and paste correctly....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Poece of advice - I think this is probably your fourth question/thread on this topic at least. It's better to keep your question to one thread/question and then you can build on the answer and get help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 05:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303942#M64646</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-12T05:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: search a specific library if they have specific datsets with required variables then append them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303943#M64647</link>
      <description>&lt;P&gt;Patrick's solution to when you posted this question earlier is correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not use his solution? If there's a portion you don't understand, ask for clarification but it's pretty much solution except no bugs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 05:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303943#M64647</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-12T05:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: search a specific library if they have specific datsets with required variables then append them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303947#M64648</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; his solution throws a error of parenthesis at the start of the macro not found. and the executing stops</description>
      <pubDate>Wed, 12 Oct 2016 05:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303947#M64648</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-10-12T05:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: search a specific library if they have specific datsets with required variables then append them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303949#M64650</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60507"&gt;@RTelang&lt;/a&gt; wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; his solution throws a error of parenthesis at the start of the macro not found. and the executing stops&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you certain? It's possible but I can't see any mistakes in his code. Make sure to run it in a fresh session.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Worse case scenario type it out instead of copy and paste since the browser can introduce invisible characters.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 05:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303949#M64650</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-12T05:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: search a specific library if they have specific datsets with required variables then append them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303950#M64651</link>
      <description>&lt;P&gt;I tested it, you do get errors but not regarding the macro not found. The issue is the variable ID is in multiple datasets but has different types (char vs numeric) so you can't append then. Your method will have the same issue, unless your data is clean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also realize the code is appending the datasets with all variables not just the variables you've listed?&lt;/P&gt;
&lt;P&gt;You may want to add a KEEP statement to the data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 54         %macro sap(lib=,varlist=);
 55         
 56           proc sql noprint;
 57             select distinct catx(".",libname,memname) into : datalist separated by " "
 58               from dictionary.columns
 59               where
 60                 libname = 'SASHELP'
 61                 and findw("&amp;amp;varlist",strip(name),' ','i')&amp;gt;0
 62                 and memtype='DATA'
 63             ;
 64           quit;
 65         
 66           data test1;
 67             set &amp;amp;datalist;
 68           run;
 69         
 70           proc print data=work.test1 (obs=20);
 71           run;
 72         
 73         %mend;
 74         
 75         
 76         %sap(lib=sashelp,varlist=name height);
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.04 seconds
       cpu time            0.04 seconds
       
 
 
 WARNING: Multiple lengths were specified for the variable Name by input data set(s). This can cause truncation of data.
 WARNING: Multiple lengths were specified for the variable Sex by input data set(s). This can cause truncation of data.
 WARNING: Multiple lengths were specified for the variable type by input data set(s). This can cause truncation of data.
 WARNING: Multiple lengths were specified for the variable subtype by input data set(s). This can cause truncation of data.
 WARNING: Multiple lengths were specified for the variable desc by input data set(s). This can cause truncation of data.
 NOTE: There were 322 observations read from the data set SASHELP.BASEBALL.
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: There were 19 observations read from the data set SASHELP.CLASSFIT.
 NOTE: There were 4 observations read from the data set SASHELP.FEEDER.
 NOTE: There were 159 observations read from the data set SASHELP.FISH.
 NOTE: There were 3600 observations read from the data set SASHELP.GRIDDED.
 NOTE: There were 5209 observations read from the data set SASHELP.HEART.
 NOTE: There were 27 observations read from the data set SASHELP.HOLIDAY.
 NOTE: There were 1703 observations read from the data set SASHELP.SLKWXL.
 NOTE: There were 2373 observations read from the data set SASHELP.SVRTDIST.
 NOTE: There were 11 observations read from the data set SASHELP.VBPLAYRS.
 NOTE: There were 44 observations read from the data set SASHELP._CMPIDX_.
 NOTE: The data set WORK.TEST1 has 13490 observations and 87 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.09 seconds
       cpu time            0.09 seconds
       &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Oct 2016 05:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-specific-library-if-they-have-specific-datsets-with/m-p/303950#M64651</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-12T05:57:42Z</dc:date>
    </item>
  </channel>
</rss>

