<?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: SAS Coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642844#M191824</link>
    <description>&lt;P&gt;Could you please try the below code where if you pass the date then it will give you the datasets names which were created in the last 30 days. In the libname pass the library name in which the datasets are located.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(date);
data want(where=(-30&amp;lt;=diff&amp;lt;=0));
set sashelp.vtable;
where libname='ADAM';
diff=intck('day',datepart(modate),&amp;amp;date)-30;
keep libname memname diff modate ;
run;
%mend;

%test(%nrstr(today()))&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 25 Apr 2020 09:03:06 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2020-04-25T09:03:06Z</dc:date>
    <item>
      <title>SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642842#M191822</link>
      <description>&lt;P&gt;Hi Guys, I hope everyone is doing well.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need some help in building one code, I have a library with datasets from the last couple of years, I want to create a dataset with name of dataset present in the library and want to pick datasets which are present from last 30 days.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Requirement&lt;BR /&gt;Library XYZ&lt;BR /&gt;DATASET Present&lt;BR /&gt;ABC20200425&lt;BR /&gt;ABC20200424&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;ABC20190101&lt;/P&gt;&lt;P&gt;The dataset present in the library is from the start of 2019 to till date and the naming convention is the same as mentioned in the dataset present.&lt;BR /&gt;I want my output dataset to pick the last 30 days file only, it must be dynamic whatever date I will provide from there it should pick 30 days.&lt;BR /&gt;OUTPUT EXAMPLE&lt;BR /&gt;Suppose I passed date as 25th April in my code so the resulting output will be like&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATASET_NAME&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MIN_DAY&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MAX_DAY&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MISSING_DATE&lt;BR /&gt;ABC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20200325&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20200425&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Missing_Date column must have all the&amp;nbsp;dates in&amp;nbsp; a comma-separated form&amp;nbsp; between 20200325 to 20200425 if any dataset is not available in the library between the min and max date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MIN_DAY is calculated on the basics of the day we pass in our code i.e. minimum day is 30 days less then the date what we pass in our code.&lt;/P&gt;&lt;P&gt;Any guidance on how should I approach will help me a lot. Thanks a lot&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 08:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642842#M191822</guid>
      <dc:creator>Vicky1003</dc:creator>
      <dc:date>2020-04-25T08:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642844#M191824</link>
      <description>&lt;P&gt;Could you please try the below code where if you pass the date then it will give you the datasets names which were created in the last 30 days. In the libname pass the library name in which the datasets are located.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(date);
data want(where=(-30&amp;lt;=diff&amp;lt;=0));
set sashelp.vtable;
where libname='ADAM';
diff=intck('day',datepart(modate),&amp;amp;date)-30;
keep libname memname diff modate ;
run;
%mend;

%test(%nrstr(today()))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Apr 2020 09:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642844#M191824</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-25T09:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642851#M191826</link>
      <description>&lt;P&gt;Thanks for the help Jag, In my case, I have to take out date from the dataset name itself i.e.&lt;/P&gt;&lt;P&gt;ABC20200425, I have to extract the date from dataset name itself which will be (20200425), and the second part in which I need to look into the library and within 30 days range, I have to find out for what all dates there is no dataset present in the library. I am trying to make changes in your code and will update it over here. Thanks for looking.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vicky&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 09:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642851#M191826</guid>
      <dc:creator>Vicky1003</dc:creator>
      <dc:date>2020-04-25T09:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642852#M191827</link>
      <description>&lt;P&gt;Please try the below code, where we can use the memname from vtable to extract the date and use it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(where=(-30&amp;lt;=diff&amp;lt;=0));
set sashelp.vtable;
where libname='ADAM';
diff=intck('day',datepart(modate),input(compress(memname,,'kd'),yymmdd8.))-30;
keep libname memname diff modate ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Apr 2020 09:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642852#M191827</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-04-25T09:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642853#M191828</link>
      <description>&lt;P&gt;Start with creating a template that has all required dataset names:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data needed;
length memname $3;
do date = today() - 30 to today();
  memname = "ABC" || put(date,yymmddn8.);
  output;
end;
keep memname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, join that with dictionary.tables to create the list of missing dates:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select trim(substr(memname,4)) into :miss_list separated by ','
from needed a left join dictionary.tables b
on b.libname = "XYZ" and a.memname = b.memname
where b.memname is missing
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Prepare and print output:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data result;
dataset_name = "ABC";
min_day = today() - 30;
max_day = today();
missing_date = "&amp;amp;missing_date";
format min_day max_day yymmddn8.;
run;

proc print data=result noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, posted from my tablet.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 09:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642853#M191828</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-25T09:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642856#M191830</link>
      <description>&lt;P&gt;Thanks a ton, Kurt for looking into it, I am able to understand how first and third block of code is working just curious about the second block where you have used a dictionary. tables Just wanted to understand how using a "dictionary. tables" help was to go into a particular library and check for a dataset with a particular name. I am kind of new to dictionary. tables so my question might sound silly to you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vicky&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 10:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642856#M191830</guid>
      <dc:creator>Vicky1003</dc:creator>
      <dc:date>2020-04-25T10:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642859#M191833</link>
      <description>&lt;P&gt;The dictionary tables contain metadata about the state of your current SAS session. They are available as tables only in SQL (in the pseudo library DICTIONARY), and as views (for use in proc and data steps) in SASHELP.&lt;/P&gt;
&lt;P&gt;DICTIONARY.TABLES (SASHELP.VTABLE) contains information about all tables in all currently assigned libraries. Take a look at SASHELP.VTABLE to find out what's in there.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 10:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642859#M191833</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-25T10:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642981#M191862</link>
      <description>&lt;P&gt;If you want to do it in one pass:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let date=%sysevalf('24APR2020'd);

data WANT;
   set ABC20: (obs=1)
       indsname= DSNAME
       end     = LASTOBS;
   length MISSING $800;
   retain MISSING   ' '
          MIN_DATE %sysfunc(intnx(day,&amp;amp;date,-30)) 
          MIN_DAY  %sysfunc(intnx(day,&amp;amp;date,-30),ymmddn8.) 
          MAX_DAY  %sysfunc(putn(&amp;amp;date,yymmddn8.)) ;
   if _N_=1 then do DT=MIN_DATE to &amp;amp;date;
     MISSING=catx(' ',MISSING,put(DT,yymmddn8.));
   end;
   MISSING=tranwrd(MISSING,compress(DSNAME,,'dk'), ' ');
   if LASTOBS then output;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 00:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/642981#M191862</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-26T00:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/643028#M191872</link>
      <description>&lt;P&gt;Thanks a lot, Kurt now I am able to understand the dictionary table part and I guess your code will help me a lot to achieve what I need. I will try to create a macro were the user can pass any date, library, and dataset name to get information about the last thirty days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the late response, Thanks.&lt;/P&gt;&lt;P&gt;Thanks, everyone over here to help me out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vicky&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 15:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/643028#M191872</guid>
      <dc:creator>Vicky1003</dc:creator>
      <dc:date>2020-04-26T15:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/643298#M191965</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;Need one help, the second part of the code is not working fine for me as the library which I am trying to hit has another dataset than ABC, the dataset name can also start with another alphabet also. Though I am applying a filter of 30 days only but if my library has a dataset that goes outside the 30 days range I want to pick that dataset details and put it in the "Missing_date" list I tried it but it's not picking correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The change I made in the middle part&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select trim(substr(memname,4)) into :miss_list separated by ','&lt;BR /&gt;from dictionary.tables a left join needed b&lt;BR /&gt;on a.libname = "XYZ" and a.memname = b.memname&lt;BR /&gt;where a.memname is missing and a.memname like "%ABC";&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gives me an error: Apparent invocation of macro ABC not resolved.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 14:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/643298#M191965</guid>
      <dc:creator>Vicky1003</dc:creator>
      <dc:date>2020-04-27T14:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/643326#M191979</link>
      <description>&lt;P&gt;When you need to use a SQL "like" wildcard, enclose the string in single quotes, so that SAS does not attempt to resolve the apparent macro trigger.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 15:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Coding/m-p/643326#M191979</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-27T15:44:45Z</dc:date>
    </item>
  </channel>
</rss>

