BookmarkSubscribeRSS Feed
tparvaiz
Obsidian | Level 7

Hi,

I have a column with dates, I want to filter records for Friday only... e.g. I want to filter March 1, 2013... Feb 22, 2013... Feb 15 2013... and so on

how can I do it?

Thanks in advance

2 REPLIES 2
Reeza
Super User

Use the weekday function.

where weekday(date)=6;

damanaulakh88
Obsidian | Level 7

Hi,

Please find below the code and its output:-

=====================================

data new;

informat mydate mmddyy10.;

input mydate ;

format mydate mmddyy10.;

datalines;

03/01/2013

03/02/2013

03/03/2013

03/04/2013

03/05/2013

03/06/2013

03/07/2013

03/08/2013

03/09/2013

03/10/2013

03/11/2013

03/12/2013

03/13/2013

;

run;

data new1(drop= month day year);

set new;

if weekday(mydate) NE 6 then delete;

run;

=====================================

Ouptut:-

============================================

                                                         Obs        mydate

                                                          1     03/01/2013

                                                          2     03/08/2013

=============================================

/Daman

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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