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
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.