I am struggling with organizing data by specific dates.
My dates are displayed in the data as "01/01/1995" through "12/31/2015". I need to drop the dates before 2000.
Any suggestions?
There can be differences between what a variable contains, vs. how it displays. To prepare, you will need to run a PROC CONTENTS on your data set and note the characteristics of the variable that holds the dates ... is it numeric or character, what is its length, does it have a format.
Jordan
Assuming your date column is numeric with a date format this is straightforward. Below is an example of deleting all rows from a copy of SASHELP.AIR where the year is earlier than 1955. You should simply follow the same method for your problem.
Chris
data air;
set sashelp.air;
run;
proc sql;
delete from air
where year(date) < 1955;
quit;
Hi:
Also, the DATA step supports a WHERE statement, so technically, you did not need the PROC SQL step at all.
cynthia
proc freq data=sashelp.air;
title '1 Before: Years in SASHELP.AIR';
tables date;
format date year4.;
run;
** subset only rows GE 1955 for year(date);
data air;
set sashelp.air;
where year(date) GE 1955;
run;
proc freq data=air;
title '2 After: only years GE 1955';
tables date;
format date year4.;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.