BookmarkSubscribeRSS Feed
epigrad
Calcite | Level 5
I have two datasets, lets call them A and B.

A is the result of a Monte Carlo simulation and has 100,000 rows - 10,000 draws of a random variable (for this example) for each of 100 IDs/subjects/whatever.

So it looks like:

Iteration ID Draw
1 1 0.073
1 2 0.987
1 3 0.487
...
2 1 0.278
2 2 0.142

etc.

I also have a data set, with these same ID numbers, and a *fixed* set of variables. I'd like to merge them such that each of the 10,000 iterations of the ID sequence gets paired with the fixed variable data set.

I think this is a fairly simple thing to do, but due to some other things running in the background, I can only manage to batch submit SAS jobs, so my usual code-tinkering techniques aren't available to me.

Will a standard Merge and By work?

For example:

data work.desired;
merge work.a work.b;
by ID;
run;

?
1 REPLY 1
ballardw
Super User
proc sql;
create work.desired as
select work.a.iteration,work.a.draw, work.b.*
from work.a left join work.b on work.a.id=work.b.id
;
quit;

Might work for you. Sql joins often run quicker than MERGE on large data sets.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 692 views
  • 0 likes
  • 2 in conversation