I am trying to combine 8 datasets of different patient data captured in 6 month intervals in 2 different hospitals. So, I have to combine those 8 datasets so that I have one nice dataset that I could work on.
When I try to combine using
data Combined; set fullextract1 fullextract2 fullextract3 fullextract4 fullextract5 fullextract6 fullextract7 fullextract8;
run;
I get multiple variables have been defined both as character and numeric like this:
ERROR: Variable DOB has been defined as both character and numeric.
So, I tried to put this in data statement for all involved variables in the individual datasets (basically trying to convert to character variables):
DOBch= put (DOB, $7.);
drop DOB; rename DOBch=DOB;
But, still when finally try to combine using above combine statement, I still get these error statements. Please help.
Try to do your conversions this way :
data fullExtract1;
set fullExtract1(rename=(DOB=DOBnum));
DOB = put(DOBnum, 7.);
drop DOBnum;
run;
PG
Try to do your conversions this way :
data fullExtract1;
set fullExtract1(rename=(DOB=DOBnum));
DOB = put(DOBnum, 7.);
drop DOBnum;
run;
PG
Thanks a lot !!!!
It worked very well...Much appreciated..Venki
Just so I'm clear...The guidance is to convert the variables in each individual dataset before joining, correct?
You can convert as you join. RENAME the wrongly typed variables in the SET statement, convert them in the code, assign the result to the properly named variables, and drop the renamed variable. You can do for multiple datasets the same as I proposed in this old post for a single dataset
How would I combine two cases of your solution?
data nicholas._21305_21501 ;
set nicholas._21305_21501 (rename=(i1_Value=i1_Value_Character)) ;
i1_Value = put(i1_Value_Character, 1.) ;
drop i1_Value_Character ;
run ;
data nicholas._21305_21501 ;
set nicholas._21305_21501 (rename=(i2_Value=i2_Value_Character)) ;
i2_Value = put(i2_Value_Character, 1.) ;
drop i2_Value_Character ;
run ;
data nicholas._21305_21501 ;
set nicholas._21305_21501 (rename=(i1_Value=i1_Value_Character i2_Value=i2_Value_Character)) ;
i1_Value = put(i1_Value_Character, 1.) ;
i2_Value = put(i2_Value_Character, 1.) ;
drop i1_Value_Character i2_Value_Character ;
run ;
and so on, for all wrong typed variables.
I had the same problem, but when I do this, in my final table there are no values for "p_no". There is a column, but the values are missing.. What can I do about it? Something with the ''7.''? What does that mean?
DATA fullExtract1 (rename=(respno=p_nonum));
SET fullExtract1;
p_no = put(p_nonum, 7.);
DROP p_nonum;
RUN;
Start a new forum topic, post the log and an example of the value of respno.
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!
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.