BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
talktorob
Calcite | Level 5

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;

 

 

Merged estimates.jpgMerged dataset.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

 

 

Merged estimates.jpgMerged dataset.jpg


 

View solution in original post

2 REPLIES 2
Reeza
Super User

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;

 

 

Merged estimates.jpgMerged dataset.jpg


 

talktorob
Calcite | Level 5

Hi Reeza,

 

Thank you so much for your explanation. Your code worked! Much appreciated.

 

Regards,

Robert

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1145 views
  • 0 likes
  • 2 in conversation