BookmarkSubscribeRSS Feed
SChander
Calcite | Level 5

Hi everyone,

 

I want to add more data columns in SAS data. Please help me out.

for example;

 

I have data of 13k patients, there is missing hemoglobin value in the data. How can I add new column which also match to patient's other data.

 

Thanks,

 

 

2 REPLIES 2
Tom
Super User Tom
Super User

Where are these hemoglobin values going to come from?

 

Normally you would not ADD a variable to an existing dataset.

 

The normal way would be create a dataset that has the data for the new variable and merge the two datasets to make a NEW dataset that has the NEW structure.  Make sure both datasets have the proper key variables so the values of hemoglobin are adding into the right observations of the old dataset.

So for example if your existing data is called HAVE and each row is uniquely identified by the variable PATIENT and you have created a new dataset called HEMOGLOBIN that has the new variable with the hemoglobin values and also has the PATIENT variable then you can make an new dataset called WANT that has all of the data together.

data want;
  merge have hemoglobin  ;
  by patient;
run;

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!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 2 replies
  • 398 views
  • 0 likes
  • 3 in conversation