I have more than 80 variables for patients with multiple ID .
the data looks like:
ID | da | aw | gd | etc. |
1 | 1 | . | . | |
1 | . | 1 | . | |
1 | . | 1 | . | |
1 | . | . | . | |
2 | . | 1 | 1 | |
2 | . | . | 1 | |
3 | . | . | . | |
3 | 1 | . | . | |
3 | . | . | . |
how can I repeat the same value for each variable for the same ID, So the data would like this
ID | da | aw | gd | etc. |
1 | 1 | 1 | . | |
1 | 1 | 1 | . | |
1 | 1 | 1 | . | |
1 | 1 | 1 | . | |
2 | . | 1 | 1 | |
2 | . | 1 | 1 | |
3 | 1 | . | . | |
3 | 1 | . | . | |
3 | 1 | . | . |
Thank you for your response, I did not mention earlier than I also have around 4 million observations, merging any file takes time and freezes the software, is there a way around it?
The data step merge usually doesn't require much computer resorrces, like sorting, SQL joins and aggregation steps.
So the questions is what's going on in your computer?
Make sure you have the necessary space for your saswork location.
Check any Windows logs for messages, and also Task Manager while executing your step.
Buy a new computer? Pretty much any computer built in the last 10 years could handle this amount of data in less than a minute. So try it this way.
Take a subset of your data (let's say ID values of 1, 2, and 3). Get the program working for that subset. Once you have a working program, try applying it to the full data set.
Good luck.
this is a new computer I only had it for a month but every time I run the whole dataset the sas software not the computer freezes.
@HijB wrote:
this is a new computer I only had it for a month but every time I run the whole dataset the sas software not the computer freezes.
Strange, this should not happen. Are the latest updates applied to the sas installation? How much memory is installed?
Why do you want to keep n obs for each patient all having the same data?
Double DOW-loop can do it too:
data have;
input ID da aw gd;
cards;
1 1 . .
1 . 1 .
1 . 1 .
1 . . .
2 . 1 1
2 . . 1
3 . . .
3 1 . .
3 . . .
;
run;
proc print;
run;
%let list_of_vars = da aw gd;
%let num_of_vars = 3;
data want;
do until(last.ID);
set have;
by ID;
array V(i) &list_of_vars.;
array T [&num_of_vars.];
drop t:;
do over V;
t[i] = V <> t[i];
end;
end;
do over V;
V = t[i];
end;
do until(last.ID);
set have(drop=&list_of_vars.);
by ID;
output;
end;
run;
proc print;
run;
Bart
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.