DATA Step, Macro, Functions and more

Subset dataset by date

Reply
Occasional Contributor
Posts: 12

Subset dataset by date

[ Edited ]

hi ,

this isate ganesh, i have one doubt ,

 

id     name    date

101  xxx      19/05/15

102 YYY      19/06/16

103 zzz       19/05/15

 

i want '19/05/15' date values  into output dataset ,how to solve this probleam .

 

Regards

A.Ganesh

Occasional Contributor
Posts: 12

subset date value

hi ,

this is ganesh, i have one doubt ,

 

id     name    date

101  xxx      19/05/15

102 YYY      19/06/16

103 zzz       19/05/15

 

i want '19/05/15' date values only  into output dataset ,how to solve this probleam .

 

Regards

A.Ganesh

Super User
Posts: 5,256

Re: subset date date

Please elaborate.

Is the example data from an external file?

And you wish to store it in a SAS data set (output)?

Use an informat to translate the date into a SAS date numerical variable.

Data never sleeps
Occasional Contributor
Posts: 12

Re: subset date date

that values are stored in sas dataset,how to subset particular date values

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super User
Super User
Posts: 7,401

Re: subset date date

Hi,

 

Is date a numeric variable or character.  Depending on that you could use where clause or if etc.

data want;
  set have;
  where date="19/05/15";
run;

or 

data want;
  set have;
  where date=input("19/05/15",ddmmyy8.);
run;
Occasional Contributor
Posts: 12

Re: subset date date

tq

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super User
Posts: 17,819

Re: Subset dataset by date

If you have a SAS date you can use the following to filter.

 

You can specify a date constant in SAS using the date9 format and with a d after the date.

 

"05Sep2015"d

Or you can use the MDY function to create a SAS date

 

mdy(5, 19, 15)

 

Ask a Question
Discussion stats
  • 6 replies
  • 254 views
  • 0 likes
  • 4 in conversation