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 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1253 views
  • 1 like
  • 2 in conversation