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;