BookmarkSubscribeRSS Feed
Lightyears
Calcite | Level 5
Hi new to SAS. I have a date in a table that comes back in the format of character

Dateto
20200214

How in my project can I get it to display as a date in UK format.

Dateto
14/02/2020

Any help grateful. Thank you.
8 REPLIES 8
PaigeMiller
Diamond | Level 26
data want;
     chardate='20200214';
     numdate=input(chardate,yymmdd8.);
     format numdate yymmdds10.;
run;
--
Paige Miller
Lightyears
Calcite | Level 5
Thanks. When adding it to my select statement in my program, do I replace where you put the actual date entered in the field with the field name ‘dateto’?
SASKiwi
PROC Star

To answer your question we need to see your actual code.

Lightyears
Calcite | Level 5

as SELECT DISTINCT

t2.ac,

t1.ext_ui

t1.vkonto,

t1.vkbez as sap_name,

t1.einzdat as dateto,

t1.auszdat as datefrom

 

FROM analytics_temp_user.List t2 inner join analytics_pm6.ALLSAPDATA t1

PaigeMiller
Diamond | Level 26
input(t1.einzdat,yyddmm8.) as dateto format=yymmdds10.,
--
Paige Miller
Tom
Super User Tom
Super User

You can replace the reference to the existing variable with the function call. Attach the format to control how the resulting date values are displayed.

SELECT DISTINCT
 t2.ac
,t1.ext_ui
,t1.vkonto
,t1.vkbez as sap_name
,input(t1.einzdat,yymmdd8.) as dateto format=ddmmyy10.
,input(t1.auszdat,yymmdd8.) as datefrom format=ddmmyy10.
FROM analytics_temp_user.List t2
  inner join analytics_pm6.ALLSAPDATA t1
Lightyears
Calcite | Level 5
Thanks all. I put it in as below but get this error.

ERROR: Execute error: org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line
1:522 cannot recognize input near 'yymmdd8' '.' ')' in select expression

as SELECT DISTINCT
t2.ac,
t1.ext_ui,
t1.vkonto,
t1.vkbez as sap_name,
input(t1.einzdat,yymmdd8.) as dateto format=ddmmyy10.,
input(t1.auszdat,yymmdd8.) as datefrom format=ddmmyy10.

FROM analytics_temp_user.List t2
inner join analytics_pm6.ALLSAPDATA t1

PaigeMiller
Diamond | Level 26

Please do not show us the errors separated from the code. Please do show us the entire LOG for your PROC SQL step, with nothing chopped out, in the order that it appears in the LOG.

 

Please also help us out by formatting the log properly by copying it as text and pasting it into the window that appears when you click on the </> icon. PLEASE DO NOT SKIP THIS STEP. I no longer try to read logs that are not formatted properly.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 8 replies
  • 980 views
  • 2 likes
  • 4 in conversation