BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

%macro combine;

 

data lm_all;

  set

%do i=1 %to 24;

   lossmit.loss_mit_settlements_&last_month.*/ (keep=loan_number type actual_completion_date)

%end;

  ;

run;

 

%mend;

 

%combine;

 

This code at one time pulled a dataset that already compiled loss_mit settlements into one dataset for the previous month

(ie       loss_mit_settlements_20160201

           loss_mit_settlements_20160202

loss_mit_settlements_20160203  

 

was automatically compiled into one previous month dataset called loss_mit_settlements_201602

 

The data no longer offers this. It separates each data set individually. Is there a way to use the same macro to compile all daily datasets into one previous month file to essentially mirror what I used to have when the dataset was combine already.

2 REPLIES 2
Astounding
PROC Star

If either of these would be appropriate, they are available:

 

data im_all;

set lossmit.loss_mit_settlements_2016: (keep=loan_number type actual_completion_date);

run;

 

data im_all;

set lossmit.loss_mit_settlements_201602: (keep=loan_number type actual_completion_date);

run;

ballardw
Super User

You would have to provide more details about the names of the data sets involved.

If this is part of an input proceess you might describe the incoming original datasets and how you read them.

 

The way your current example macro is displayed you would read a single dataset 24 times as you are not changing the name at all.

 

Note that if you have similar dataset names you can use a list modifier : to get all of the data sets that start with the same characters. For example if your datasets are loss_mit_settlements_Feb_01 loss_mit_settlements_Feb_02 loss_mit_settlements_Feb_03

then you could use

Set loss_mit_settlements_Feb_: ;

To read all of the sets that start with loss_mit_settlements_Feb_

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 2 replies
  • 1638 views
  • 0 likes
  • 3 in conversation