BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Venki
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try to do your conversions this way :

data fullExtract1;

set fullExtract1(rename=(DOB=DOBnum));

DOB = put(DOBnum, 7.);

drop DOBnum;

run;

PG

PG

View solution in original post

8 REPLIES 8
PGStats
Opal | Level 21

Try to do your conversions this way :

data fullExtract1;

set fullExtract1(rename=(DOB=DOBnum));

DOB = put(DOBnum, 7.);

drop DOBnum;

run;

PG

PG
Venki
Calcite | Level 5

Thanks a lot !!!!

It worked very well...Much appreciated..Venki

_maldini_
Barite | Level 11

@PGStats 

 

Just so I'm clear...The guidance is to convert the variables in each individual dataset before joining, correct?

PGStats
Opal | Level 21

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

PG
NKormanik
Barite | Level 11

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 ;

 

PGStats
Opal | Level 21

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.

PG
hovliza
Obsidian | Level 7

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;

 

PGStats
Opal | Level 21

Start a new forum topic, post the log and an example of the value of respno.

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 8 replies
  • 60706 views
  • 0 likes
  • 5 in conversation