BookmarkSubscribeRSS Feed
mehak
Calcite | Level 5

Can anyone please tell me how can i subset the data after a  given date  . I think i have to use date fn . But dnt know how to keep date in a conditional statement how to find variable informat . ?

10 REPLIES 10
mehak
Calcite | Level 5

how can i seperate out the data launged after 20 jan 1990 from vechiles

kiranv_
Rhodochrosite | Level 12

date gt '20JAN1990'

mehak
Calcite | Level 5

sir i want to get all the date after 20 jan . Then what i should do ?

Reeza
Super User

You should read this chapter. 

http://documentation.sas.com/?docsetId=lrcon&docsetTarget=p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm&docsetVer...

 

You can filter dates with a standard IF/WHERE statement, but you need to use dates with the proper format. 

 

'01JAN2017'd -> note the quotes, 3 letter month, and d after the quotes

 

data want;
set sashelp.stocks;

where date > '01Jan2000'd;

run;
Kurt_Bremser
Super User

Please post some example data, and which rows you want selected/not selected.

Basically, you can use a where condition or a subsetting if.

mehak
Calcite | Level 5

i have attached the sample  data set . Can you please know tell me how can i seperate out data for passangers vehicles launced after 20 jan .

error_prone
Barite | Level 11
You have attached a csv-file, not a dataset. Please post the code you wrote to import that file.
mehak
Calcite | Level 5
libname _class_s "/folders/myfolders/ 1";

PROC IMPORT DATAFILE="/folders/myfolders/1/Car_sales.csv"
OUT=_class_s.Car_sales
DBMS=csv
REPLACE;
RUN;

 I have used the above code to import the file and it has import succesfully as i am able to see all the data present in my car file.

andreas_lds
Jade | Level 19

proc imports recognizes Latest_Launch as SAS-date, so use the example code posted by @Reeza.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 10 replies
  • 2728 views
  • 2 likes
  • 6 in conversation