BookmarkSubscribeRSS Feed
mhodge20
Calcite | Level 5

I didnt mean to put the spolier lines there. grey bars showed up and I didnt know what they were or how to remove them.

 

But this is what im trying to Accomplish.

 

I have a list of datasets that are sequentially names with year and month. Ex. Perf_200504 - Perf_201801

 

I have a list of dates in another table by client.

 

I am trying to stack client relevant data.

 

So if client 1234 date is 01/01/2016, stack all client information from each dataset.

 

So I need to loop through each dataset from the point of a specific date and stack all later datasets.

 

Hope this makes sense

Astounding
PROC Star

OK, some key information then:

 

  • What is the LIBNAME for the folder holding the data?
  • What is the LIBNAME for the separate table holding the list of clients?
  • In that list of clients, how is that date field stored?  As a character string?  As a SAS date?  What is the actual value, and what is the formatted value (if that's different than the actual value)?

Can I assume from your example (where the date is 01/01/2016) that you want to extract everything from Perf_201601, everything from Perf_201602, all the way through everything from Perf_201801? 

mhodge20
Calcite | Level 5
libname for perf data is perf
list of clients and dates are in work, in dataset called clients

The date is a sas date formatted as MMDDYY10.

and the assumption at the bottom is correct
Astounding
PROC Star

One way to go:

 

%macro one_client (client=);

   %local starting_ym dataset_list;

   data start;

      set clients;

      where client = &client;

      call symputx('starting_ym', catt(year(date), month(date));

   run;

   proc sql;

      select distinct 'perf.' || memname into : dataset_list separated by ' '

      from dictionary.tables

      where substr(upcase(memname), 1, 5)) = 'PERF_' and substr(memname, 6, 6) >= "&starting_ym"

      ;

   quit;

   data want;

      set &dataset_list;

   run;

 

%mend one_client;

 

Obviously, it's untested code.  Minor tweaks might be needed.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 18 replies
  • 3736 views
  • 1 like
  • 5 in conversation