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
SAS Super FREQ

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 591 views
  • 0 likes
  • 4 in conversation