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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 495 views
  • 0 likes
  • 3 in conversation