BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SciFiGuy0
Obsidian | Level 7

I've got a dataset containing a date field named Submitted:

01Jan2015

01Jan2015

01Jan2015

02Jan2015

03Jan2015

 

I'm running a simple query builder which produces this code:

PROC SQL;

CREATE TABLE WORK.Stuff AS

SELECT DISTINCT t1.Submitted

FROM WORK.INPUTSET t1

ORDER BY t1.Submitted;

QUIT;

 

The output result is:

01Jan2015

01Jan2015

01Jan2015

02Jan2015

03Jan2015

 

Shouldn't there only be three records in the output file? 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

If your date field is a SAS date, it may contain a fractional part, try using

 

CREATE TABLE WORK.Stuff AS
SELECT DISTINCT round(t1.Submitted) as Submitted format=date9.
FROM WORK.INPUTSET t1
ORDER BY Submitted;
QUIT;

if your date field is a SAS datetime, it may contain a time value, try using

 

CREATE TABLE WORK.Stuff AS
SELECT DISTINCT datepart(t1.Submitted) as Submitted format=date9.
FROM WORK.INPUTSET t1
ORDER BY Submitted;
QUIT;

 

PG

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

If your date field is a SAS date, it may contain a fractional part, try using

 

CREATE TABLE WORK.Stuff AS
SELECT DISTINCT round(t1.Submitted) as Submitted format=date9.
FROM WORK.INPUTSET t1
ORDER BY Submitted;
QUIT;

if your date field is a SAS datetime, it may contain a time value, try using

 

CREATE TABLE WORK.Stuff AS
SELECT DISTINCT datepart(t1.Submitted) as Submitted format=date9.
FROM WORK.INPUTSET t1
ORDER BY Submitted;
QUIT;

 

PG

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2438 views
  • 0 likes
  • 2 in conversation