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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 1000 views
  • 0 likes
  • 2 in conversation