BookmarkSubscribeRSS Feed
Jordan1
Calcite | Level 5

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?

3 REPLIES 3
Astounding
PROC Star

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.

ChrisBrooks
Ammonite | Level 13

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;
Cynthia_sas
Diamond | Level 26

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;

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