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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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