Hi,
Need help please..
I am trying to convert numeric date variable into character date variable.
PROC SQL;
CREATE TABLE y AS
SELECT PUT(subjid, 6.) AS subjid,
PUT(date, 20.) AS date FORMAT = YYMMDD10.
FROM x;
QUIT;
423 PROC SQL;
424 CREATE TABLE y AS
425 SELECT PUT(subjid, 6.) AS subjid,
426 PUT(date, 20.) AS date FORMAT = date9.
427 FROM x;
ERROR: Character expression requires a character format.
428 QUIT;
NOTE: The SAS System stopped processing this step because of errors.
both subjid and date are numeric variables and i want to convert into character variables for merging.
Are there any other ways of doing this conversion?
Thank you
Anu.
Editor's note: Thanks to Aishwarya for showing how to use the PUT function to apply the YYMMDD10. format. Using the YYMMDD10. format along wtih the PUT function will convert the SAS date to a character string in the format of YYYY-MM-DD.
Hi Aishwarya,
For the conversion of numeric value to character value try the following code
PROC SQL;
CREATE TABLE y AS
SELECT PUT(x.subjid, 6.) AS subjid,
PUT(x.date, YYMMDD10. ) AS date
FROM x;
QUIT;
Now this column was converted into character so you can not applied numeric formate on that
Editor's note: Thanks to Aishwarya for showing how to use the PUT function to apply the YYMMDD10. format. Using the YYMMDD10. format along wtih the PUT function will convert the SAS date to a character string in the format of YYYY-MM-DD.
Hi Aishwarya,
For the conversion of numeric value to character value try the following code
PROC SQL;
CREATE TABLE y AS
SELECT PUT(x.subjid, 6.) AS subjid,
PUT(x.date, YYMMDD10. ) AS date
FROM x;
QUIT;
Now this column was converted into character so you can not applied numeric formate on that
Thank you
Welcome
Hi please try the below one....in the below example shows how to convert numeric date values to character ones..
data dates;
informat A date9.;
input A;
cards;
13/APR/1999
01/JAN/1960
31/JAN/1960
;
run;
data converted;
set dates;
dates_char = put(a,date9.);
run;
Hi,
how is it possible to convert a numeric date field into character value using an expression in SAS Data Integration Studio?
Thanks in advance.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.