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

Hi,

Need help on SAS. Check below queries:

Query 1: SELECT Publication_Date FROM test(obs=1);

Output: 2000-04-23

Query 2: SELECT MIN(Publication_Date) FROM test;

Output: 14723

NOTE: Publication_Date is of DATE type. I am using SAS 9.2 and testing above queries through JDBC layer and analyzing the resultset metadata.

Now for query 2, I need to get the output as SAS sql type Date but not as some NUMBER as in above case.

NOTE: Same query 2 in all other database vendors like oracle, MySql returns back the result in Date data type only.

I also tried below query but it doesn't solve my purpose. This query returns String but not DATE data type. Smiley Sad

SELECT put(MIN(Publication_Date),yymmdd10.) FROM test;

Output: "2000-04-23"

Please help?

1 ACCEPTED SOLUTION

Accepted Solutions
shivas
Pyrite | Level 9

Hi,

Try this...Hope this helps..

data test;

input Publication_Date:date9.;

cards;

01dec2012

01mar2012

;

run;

proc sql;

create table want as

SELECT MIN(Publication_Date) as date format=date9. FROM test;

quit;

Thanks,

Shiva

View solution in original post

3 REPLIES 3
shivas
Pyrite | Level 9

Hi,

Try this...Hope this helps..

data test;

input Publication_Date:date9.;

cards;

01dec2012

01mar2012

;

run;

proc sql;

create table want as

SELECT MIN(Publication_Date) as date format=date9. FROM test;

quit;

Thanks,

Shiva

nitesh_k
Calcite | Level 5

Thanks Shiva. It did helped. I too got it from some other related posts.  Smiley Happy

nitesh_k
Calcite | Level 5

Got one solution. Thanks to "More like this" link which appears after we post the discussion.

Need to specify alias and format as below:

SELECT MIN(Publication_Date) as mindate format=Date9. FROM test;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 19794 views
  • 4 likes
  • 2 in conversation