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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 18 replies
  • 4118 views
  • 1 like
  • 5 in conversation