Organizing Date's

Reply
New User
Posts: 1

Organizing Date's

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?

Respected Advisor
Posts: 4,972

Re: Organizing Date's

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.

Frequent Contributor
Posts: 119

Re: Organizing Date's

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;
SAS Super FREQ
Posts: 8,719

Re: Organizing Date's

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;
Ask a Question
Discussion stats
  • 3 replies
  • 271 views
  • 0 likes
  • 4 in conversation