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_

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!

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