I have one file that contains parameter estimates (36 different values) [this is the screenshot called ‘merged estimates’. This file does not contain any patient IDs, demographics, etc.
I have a second file that contains my study sample sorted by patient ID (9,965 participants). I would like to merge both files so that each participant has the same sequence of 36 values.
My current output only has the sequence of 36 values for the 1st observation [second screenshot called ‘merged dataset’].
Thank you so much for your suggestions.
This is the code I was trying to no avail.
data createBAestimate ;
merge V12 mergeestimate ;
do i = 1 to 9965 ;
output ;
end;
run;
You can't merge in one row to a full data set this way.
This will work for you though:
data createBAestimate;
set V12;
if _n_ =1 then set mergeestimate;
run;
Without a BY statement, the merge operates by position, on a line by line merge so the first rows are merged and then nothing as you've seen.
FYI if you're trying to score data, look into PROC PLM.
@talktorob wrote:
I have one file that contains parameter estimates (36 different values) [this is the screenshot called ‘merged estimates’. This file does not contain any patient IDs, demographics, etc.
I have a second file that contains my study sample sorted by patient ID (9,965 participants). I would like to merge both files so that each participant has the same sequence of 36 values.
My current output only has the sequence of 36 values for the 1st observation [second screenshot called ‘merged dataset’].
Thank you so much for your suggestions.
This is the code I was trying to no avail.
data createBAestimate ;
merge V12 mergeestimate ;
do i = 1 to 9965 ;
output ;
end;
run;
You can't merge in one row to a full data set this way.
This will work for you though:
data createBAestimate;
set V12;
if _n_ =1 then set mergeestimate;
run;
Without a BY statement, the merge operates by position, on a line by line merge so the first rows are merged and then nothing as you've seen.
FYI if you're trying to score data, look into PROC PLM.
@talktorob wrote:
I have one file that contains parameter estimates (36 different values) [this is the screenshot called ‘merged estimates’. This file does not contain any patient IDs, demographics, etc.
I have a second file that contains my study sample sorted by patient ID (9,965 participants). I would like to merge both files so that each participant has the same sequence of 36 values.
My current output only has the sequence of 36 values for the 1st observation [second screenshot called ‘merged dataset’].
Thank you so much for your suggestions.
This is the code I was trying to no avail.
data createBAestimate ;
merge V12 mergeestimate ;
do i = 1 to 9965 ;
output ;
end;
run;
Hi Reeza,
Thank you so much for your explanation. Your code worked! Much appreciated.
Regards,
Robert
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.