I am trying to convert a numeric variable eg 123654 to character. i used this code
data CDCDATA.Finaldata_CDC_ptid;
set CDCDATA.Finaldata_CDC;
patientid = put(cl_patientid,8.);
run;
th slog says;
/*Reformating numeric Patient ID to Character format*/
data CDCDATA.Finaldata_CDC_ptid;
set CDCDATA.Finaldata_CDC;
patientid = put(cl_patientid,8.);
run;
the variable did not change to character. What is wrong with my code?
can you post your log for the program
@Dhana18 wrote:
I am trying to convert a numeric variable eg 123654 to character. i used this code
data CDCDATA.Finaldata_CDC_ptid;
set CDCDATA.Finaldata_CDC;
patientid = put(cl_patientid,8.);
run;th slog says;
/*Reformating numeric Patient ID to Character format*/
data CDCDATA.Finaldata_CDC_ptid;
set CDCDATA.Finaldata_CDC;
patientid = put(cl_patientid,8.);
run;the variable did not change to character. What is wrong with my code?
Did you already have a variable patiend9d in the dataset? If so you cannot change the TYPE once it is created. You likely have a note like this:
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
That means you attempted to assign a character value (the put) into a numeric variable and was converted so that the existing numeric variable could hold the new value, assuming it would convert.
Question: Why the concern over it being character or numeric?
@Dhana18 wrote:
I did not get any note.
So, how do you know it did not "change to character"?
Show use your log from running your code. Copy from the log and paste into a code box opened using the forum's {I} icon. Include all the notes at the end of the data step.
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.