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.
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.
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.