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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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