BookmarkSubscribeRSS Feed
Nilesh1603
Fluorite | Level 6

I have a Data set as below.

 

1) Data Project2.Patient_Demographics;
Input Patient_ID $1-6
Age 7-9
Gender $11
Race $ 12-17
Ethnicity $ 18-30;
Datalines;
00001 54 M White Non-Hispanic
00002 42 F Black Hispanic
00003 67 M Asian Non-Hispanic
00004 35 F White Hispanic
00005 72 F Other Non-Hispanic
00006 28 M White Non-Hispanic
00007 56 F Black Non-Hispanic
00008 41 M Asian Hispanic
00009 63 F Other Hispanic
00010 39 M White Non-Hispanic
00011 45 F Black Non-Hispanic
00012 58 M Asian Non-Hispanic
00013 29 F White Non-Hispanic
00014 64 F Other Non-Hispanic
00015 32 M White Non-Hispanic
;
run;

 

2) Data Project2.treatment_details;
input patient_id 1-5
treatment_type & :$20.
start_date :mmddyy10.
end_date :mmddyy10.
response & :$20.;
datalines;
00001 Chemotherapy 01/01/2023 03/31/2023 Partial Response
00002 Immunotherapy 02/15/2023 05/15/2023 Complete Response
00003 Targeted Therapy 03/01/2023 06/30/2023 Stable Disease
00004 Chemotherapy 04/10/2023 07/10/2023 Progressive Disease
00005 Immunotherapy 05/20/2023 08/20/2023 Partial Response
00006 Chemotherapy 06/01/2023 09/30/2023 Complete Response
00007 Targeted Therapy 07/15/2023 10/15/2023 Stable Disease
00008 Chemotherapy 08/10/2023 11/10/2023 Progressive Disease
00009 Immunotherapy 09/20/2023 12/20/2023 Partial Response
00010 Targeted Therapy 10/01/2023 01/31/2024 Complete Response
run;

 

Query: But when I am trying to merge the data by below query, OI am getting below error.

"ERROR: Variable Patient_ID has been defined as both character and numeric."

data merged_data;
merge patient_demographics treatment_details;
by patient_id;
run;

 

Please help me with this.

5 REPLIES 5
Patrick
Opal | Level 21

Your 2nd data step as posted executes with errors. Is this just creating sample data or what you're really doing?

Nilesh1603
Fluorite | Level 6
I have started SAS base course and this is the Chapter exercise
Patrick
Opal | Level 21

@Nilesh1603 wrote:
I have started SAS base course and this is the Chapter exercise

The 2nd data step as posted can't work. Are you sure you copy/pasted this code from training material 1:1? 

Is this official SAS training? And if so: Which one? 

 

@Cynthia_sas Sorry, forgot where people get support for SAS training questions.

Cynthia_sas
SAS Super FREQ
Hi:
If the student is reporting a problem with one of our SAS Education e-learning classes, then they can report the problem to elearn@sas.com and the instructors on duty will investigate and help.
Cynthia
Kurt_Bremser
Super User

Whenever you need to post code, copy/paste it from the source into a window opened with the "little running man" button. The main posting window will reformat the text, e.g. by reducing multiple blanks to one.

The & modifier in the INPUT statement needs two consef'cutive blanks as delimiter to work.

Your second DATA step reads patient_id as numeric. Maybe fixing that mistake is part of the exercise.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 5 replies
  • 586 views
  • 2 likes
  • 4 in conversation