<?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: Simultaneously add DatasetName &amp;amp; a QTR variable based on DSNNAME across a LIBRARY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366452#M87180</link>
    <description>&lt;P&gt;Dear RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your solution...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I do not want to concatenate them in one dataset like "want"...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add the two variables to each one of the datasets separately without merging/concarenating them..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2017 09:32:43 GMT</pubDate>
    <dc:creator>Zeus_Olympous</dc:creator>
    <dc:date>2017-06-13T09:32:43Z</dc:date>
    <item>
      <title>Simultaneously add DatasetName &amp; a QTR variable based on DSNNAME across a LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366445#M87175</link>
      <description>&lt;P&gt;Dear all, I have a Library WKFTMP that includes groups of datasets that are named e.g&lt;/P&gt;&lt;P&gt;TRD_PRO_TOL_201604, TRD_PRO_TOL_201605, TRD_PRO_TOL_201606 etc. only the month gets changed.......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other group of datasets are named LATONIV_BAG_WAV_201604, LATONIV_BAG_WAV_201605, LATONIV_BAG_WAV_201606 etc. again only the month gets changed...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and another group of datasets named as HJK_FLD_201604, HJK_FLD_201605, HJK_FLD_201606 etc.again only the month gets changed.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like first to add a variable to &lt;STRONG&gt;each&lt;/STRONG&gt; dataset with the non numeric part of my dataset names but &lt;STRONG&gt;BASED ON A CONDITION&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-- for the first group I would like to have TRD_PRO (only the two first non-numeric part)&lt;/P&gt;&lt;P&gt;--for the second group I would like to have ALL non-numeric part e.g. LATONIV_BAG_WAV and&lt;/P&gt;&lt;P&gt;--for the third group ONLY the first non-numeric part e.g. TRD......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally in the same step or macro I would like to add a variable across all datasets with the&amp;nbsp; &lt;STRONG&gt;QUARTER&lt;/STRONG&gt; that each dataset belongs to based on the YEARMONTH string part of it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that INDSNAME feature helps....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion or hint would be more than welcome thank you in advance&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366445#M87175</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-06-13T09:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Simultaneously add DatasetName &amp; a QTR variable based on DSNNAME across a LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366447#M87177</link>
      <description>&lt;P&gt;Just a matter of processing indsname:&lt;/P&gt;
&lt;PRE&gt;data want;
  set trd_pro_tol_:
        latoniv_bag_wav_:
        hjk_fld_: 
        indsname=tmp;
  length dsnam $200;
  dsname=scan(compress(tmp,'','d'),2,'.');
  qtr=input(cats(compress(scan(tmp,2,'.'),"_","kd"),"01"),yymmdd10.);
  format qtr ...;
run;&lt;/PRE&gt;
&lt;P&gt;And pop your required format in where ... is.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366447#M87177</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-13T09:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Simultaneously add DatasetName &amp; a QTR variable based on DSNNAME across a LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366452#M87180</link>
      <description>&lt;P&gt;Dear RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your solution...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I do not want to concatenate them in one dataset like "want"...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add the two variables to each one of the datasets separately without merging/concarenating them..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366452#M87180</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-06-13T09:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simultaneously add DatasetName &amp; a QTR variable based on DSNNAME across a LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366459#M87183</link>
      <description>&lt;P&gt;A simple metadata loop should work then:&lt;/P&gt;
&lt;PRE&gt;data trd_pro_tol_201402 trd_pro_tol_201403 latoniv_bag_wav_201506;
  set sashelp.class;
run;

data want _null_;
  set sashelp.vtable (where=(libname="WORK" and substr(memname,1,3) in ("TRD","LAT")));
  dsname=compress(memname,"_","ka");
  dt=input(compress(cats(compress(memname,"","kd"),"01"),"_"),yymmdd10.);
  call execute(cat('data ',memname,'; set ',memname,'; dsname="',dsname,'"; dt="',put(dt,date9.),'"d; format dt date9.; run;')); 
run;&lt;/PRE&gt;
&lt;P&gt;The real trick here is using the sashelp metadata with a where, for each of the rows returned a datastep is created where the dataset in the row is updated with the relevant info.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 09:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366459#M87183</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-13T09:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Simultaneously add DatasetName &amp; a QTR variable based on DSNNAME across a LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366484#M87196</link>
      <description>&lt;P&gt;Dear RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I am not that experienced with CALL EXECUTE and I fail to do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my data files are stored in a library &lt;STRONG&gt;libs&lt;/STRONG&gt; (not in WORK) which I have earlier put it in a local macro variable as&lt;/P&gt;&lt;P&gt;%LET=libga;&lt;/P&gt;&lt;P&gt;%LET=&lt;STRONG&gt;libs&lt;/STRONG&gt;&amp;nbsp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so I would like have something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call execute(cat('data &lt;FONT color="#ff0000"&gt;"&amp;amp;libga."||&amp;nbsp;&lt;/FONT&gt;',memname,'; set &lt;FONT color="#ff0000"&gt;"&amp;amp;libga."||&amp;nbsp;&lt;/FONT&gt;',memname,'; dsname="',dsname,'"; dt="',put(dt,date9.),'"d; format dt date9.; run;'));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I fail the get the right combination.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion would be much appreciated.&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 11:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366484#M87196</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-06-13T11:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Simultaneously add DatasetName &amp; a QTR variable based on DSNNAME across a LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366496#M87204</link>
      <description>&lt;P&gt;A minor updated then:&lt;/P&gt;
&lt;PRE&gt;%let libga=libs;&lt;BR /&gt;&lt;BR /&gt;data &amp;amp;libga..trd_pro_tol_201402 &amp;amp;libga..trd_pro_tol_201403 &amp;amp;libga..latoniv_bag_wav_201506;
  set sashelp.class;
run;

data want _null_;
  set sashelp.vtable (where=(libname="&amp;amp;libga." and substr(memname,1,3) in ("TRD","LAT")));
  dsname=compress(memname,"_","ka");
  dt=input(compress(cats(compress(memname,"","kd"),"01"),"_"),yymmdd10.);
  call execute(cat('data &amp;amp;libga..',memname,'; set &amp;amp;libga..',memname,'; dsname="',dsname,'"; dt="',put(dt,date9.),'"d; format dt date9.; run;')); 
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2017 12:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366496#M87204</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-13T12:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Simultaneously add DatasetName &amp; a QTR variable based on DSNNAME across a LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366508#M87208</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 12:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simultaneously-add-DatasetName-amp-a-QTR-variable-based-on/m-p/366508#M87208</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-06-13T12:35:36Z</dc:date>
    </item>
  </channel>
</rss>

