BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Illuminosa
Calcite | Level 5

I use SAS E.G. version 4.3.

There are datasets (in a folder called archive) where the names are something like this: "table_contents_[year]", where [year] = 2012, 2013, 2014, ...

For example: table_contents_2012, table_contents_2013, ..., table_contents_2016.

One of the variables of these datasets is a date variable that contains dates for that certain year.

 

I want to put the data from these datasets into one new dataset, but selecting only data as from a certain year or a certain date. How can I do this?

 

With the statement below, I can extract and put the data from ALL datasets with name "tablecontents_[year]" into a new dataset.

But I don't know how I can select data that are for example greater than or equal to year 2015 or 10SEP2015?

 

%let listOfDataTables =;

proc sql noprint;
select compress("arch." || memname)
into :listOfDataTables separated by ' ' 
from sashelp.vtable
where libname=upcase("arch") and upcase(memname) like 'tablecontents*_%' escape '*';
quit;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
where libname=upcase("arch") and input(scan(memname,-1,'_') ,best8.) gt 2015

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

First, its not a good idea to split same data up into multiplpe datasets, this just makes your life harder.  Set all your data together and have year as a column:

data want;
  length v $50;
  set table_contents_: indsname=tmp;
  v=tmp;
run;

You can process indsname to get year.  You can then simply where clause this one dataset rather than trying to loop over many.

Ksharp
Super User
where libname=upcase("arch") and input(scan(memname,-1,'_') ,best8.) gt 2015

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4715 views
  • 1 like
  • 3 in conversation