<?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 set multiple data sets with required variables into one data set using sashelp.vcolumn in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405467#M66985</link>
    <description>&lt;P&gt;Sorry, please clarify, do you mean set the dataset if the variable exists, or where the variable contains data?&amp;nbsp; If its just data, then you could simplify to:&lt;/P&gt;
&lt;PRE&gt;data all;
  set x (keep=a1 a2 all_coll rename=(b=all_coll))
  ...
  where not missing(all_coll);
run; &lt;/PRE&gt;
&lt;P&gt;Providing some example test data (in the form of a datastep) and what you want to see as output would help.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2017 10:39:43 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-10-19T10:39:43Z</dc:date>
    <item>
      <title>How to set multiple data sets with required variables into one data set using sashelp.vcolumn</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405463#M66984</link>
      <description>&lt;P&gt;I want to set multiple sas data sets with required variables based on condition in a single shot by using sashelp.vcolumns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data all;&lt;/P&gt;&lt;P&gt;set&amp;nbsp;x (keep= a1 a2 &lt;STRONG&gt;b&lt;/STRONG&gt; where = (^missing(&lt;STRONG&gt;b&lt;/STRONG&gt;))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;y&amp;nbsp;&lt;SPAN&gt;(keep= a1 a2&amp;nbsp;&lt;STRONG&gt;c&lt;/STRONG&gt; where = (^missing(&lt;STRONG&gt;c&lt;/STRONG&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;z&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(keep= a1 a2&amp;nbsp;&lt;STRONG&gt;d&amp;nbsp;&lt;/STRONG&gt;where = (^missing(&lt;STRONG&gt;d&lt;/STRONG&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; zz&amp;nbsp;(keep= a1 a2&amp;nbsp;e&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;where = (^missing(&lt;STRONG&gt;e&lt;/STRONG&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;........ so on....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;data set o/p&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;a2&lt;/TD&gt;&lt;TD&gt;all_col&lt;/TD&gt;&lt;TD&gt;val&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aa&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aa&lt;/TD&gt;&lt;TD&gt;a2&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;bb&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;bb&lt;/TD&gt;&lt;TD&gt;a2&lt;/TD&gt;&lt;TD&gt;e&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 19 Oct 2017 10:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405463#M66984</guid>
      <dc:creator>SrikanthY</dc:creator>
      <dc:date>2017-10-19T10:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to set multiple data sets with required variables into one data set using sashelp.vcolumn</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405467#M66985</link>
      <description>&lt;P&gt;Sorry, please clarify, do you mean set the dataset if the variable exists, or where the variable contains data?&amp;nbsp; If its just data, then you could simplify to:&lt;/P&gt;
&lt;PRE&gt;data all;
  set x (keep=a1 a2 all_coll rename=(b=all_coll))
  ...
  where not missing(all_coll);
run; &lt;/PRE&gt;
&lt;P&gt;Providing some example test data (in the form of a datastep) and what you want to see as output would help.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 10:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405467#M66985</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-19T10:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to set multiple data sets with required variables into one data set using sashelp.vcolumn</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405470#M66986</link>
      <description>should check if data set exist or not and then variable and then data..&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Oct 2017 10:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405470#M66986</guid>
      <dc:creator>SrikanthY</dc:creator>
      <dc:date>2017-10-19T10:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to set multiple data sets with required variables into one data set using sashelp.vcolumn</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405474#M66987</link>
      <description>&lt;P&gt;Still guessing here as your not providing much info.&amp;nbsp; You can try something like this, assuming your data is in work library, and your list of variables is a and b in every dataset,and c d or f being the ones you want to check:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vcolumn (where=(libname="WORK" and name in ("C","D","E")) end=last;
  if _n_=1 then call execute('data want; set ');
  call execute(cat(memname,' (keep=a b ',name,' where=(not missing(',name,'))) '));
  if last then call execute(';run;');
run;&lt;/PRE&gt;
&lt;P&gt;So this will for each dataset which has a variable C D or E, add to the set statement which is generated keeping a b and the variable from that list.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 11:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405474#M66987</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-19T11:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to set multiple data sets with required variables into one data set using sashelp.vcolumn</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405576#M66990</link>
      <description>&lt;P&gt;How do you know to check if a data set exists? If you're using the SASHELP table, the data set has to exist already so there's something in your logic that's not clear.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please take the time to provide more details if you want help.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 14:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405576#M66990</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-19T14:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to set multiple data sets with required variables into one data set using sashelp.vcolumn</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405946#M67005</link>
      <description>thank you for your logic. bit I have modified its working.&lt;BR /&gt;but I want one more column which variable is getting output.&lt;BR /&gt;&lt;BR /&gt;for example: if variable is 'C' or 'D' or 'E'&lt;BR /&gt;then&lt;BR /&gt;colmn&lt;BR /&gt;C&lt;BR /&gt;D&lt;BR /&gt;E&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;modified prog:&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set sashelp.vcolumn (where=(libname="WORK" and name in ("C","D","E"))&lt;BR /&gt;end=last;&lt;BR /&gt;if _n_=1 then call execute('data want; set ');&lt;BR /&gt;call execute(cat('libA.',memname,' (keep=a b ',name, 'rename =(',name, '=&lt;BR /&gt;col1) where=(not missing(',name,'))) '));&lt;BR /&gt;if last then call execute(';run;');&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I am getting error when I am trying to include:&lt;BR /&gt;call execute('; colmn = ' || name );&lt;BR /&gt;&lt;BR /&gt;ERROR: data step component object failure.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Oct 2017 13:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405946#M67005</guid>
      <dc:creator>SrikanthY</dc:creator>
      <dc:date>2017-10-20T13:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to set multiple data sets with required variables into one data set using sashelp.vcolumn</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405963#M67007</link>
      <description>&lt;P&gt;Have a step after that to do the final part:&lt;/P&gt;
&lt;PRE&gt;data ds1;
  a=1; b=2; c=3;
run;

data ds2;
  a=2; b=3; d=1;
run;

data ds3;
  a=3; b=4; e=5;
run;

data _null_;
  set sashelp.vcolumn (where=(libname="WORK" and upcase(name) in ("C","D","E"))) end=last;
  if _n_=1 then call execute('data want; set ');
  call execute(cat(memname,' (keep=a b ',name,' where=(not missing(',name,'))) '));
  if last then call execute(';run;');
run;

data want (keep=a b col1 from);
  set want;
  array v{*} _numeric_;
  do i=3 to dim(v);
    if v{i} ne . then do;
      col1=v{i};
      from=vname(v{i});
    end;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Oct 2017 14:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-set-multiple-data-sets-with-required-variables-into-one/m-p/405963#M67007</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-20T14:24:28Z</dc:date>
    </item>
  </channel>
</rss>

