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

I have the following dates data:

 

 

data mydates;
  infile cards truncover expandtabs;
  input Date :date9. time :time8.;
  dt = date * 86400 + time;
  format Date date9. time time8. dt datetime19.;
cards;
02Jan2016 18:50:46
04Jan2016 0:08:47
04Jan2016 5:40:23
05Jan2016 11:58:24
12Jan2016 10:06:35
24Jan2016 17:49:23
26Jan2016 9:58:08
29Jan2016 9:58:02
30Jan2016 11:48:34
02Feb2016 13:10:07
04Feb2016 9:12:03
04Feb2016 20:29:06
05Feb2016 11:18:21
06Feb2016 10:24:24
07Feb2016 1:09:35
08Feb2016 10:45:27
09Feb2016 13:10:47
10Feb2016 13:07:53
11Feb2016 13:15:14
12Feb2016 9:35:45
13Feb2016 1:11:07
15Feb2016 9:53:32
16Feb2016 9:51:57
29Jun2016 13:15:14
29Jun2016 9:35:45
06Jul2016 1:11:07
06Jul2016 9:53:32
22Sep2016 9:51:57

; run;

 

 

When I am trying to create a subset I used this... but I think this is not correct...

 

 

       PROC SQL;
             SELECT t1.*
                FROM mydates t1
                WHERE t1.Date IN
                     (
                     min(t1.Date),
'29Jun2016'd, '6Jul2016'd, max(t1.Date) ); QUIT;

 

Please help me to write correct code.

 

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

proc sql;
  create table WANT as
  select  *
  from    MYDATES
  having  DATE=min(DATE) or DATE=max(DATE);
quit;

Pretty sure I mentioned before, but if not, its not a good idea to call columns DATE or TIME, or DATETIME, expecially when you call a variable DATE and its a datatime field.  No need to code all in caps either.

 

 

 

View solution in original post

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

proc sql;
  create table WANT as
  select  *
  from    MYDATES
  having  DATE=min(DATE) or DATE=max(DATE);
quit;

Pretty sure I mentioned before, but if not, its not a good idea to call columns DATE or TIME, or DATETIME, expecially when you call a variable DATE and its a datatime field.  No need to code all in caps either.

 

 

 

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
  • 1051 views
  • 1 like
  • 2 in conversation