BookmarkSubscribeRSS Feed
Nieves
Quartz | Level 8

Hi,

 

I have a data set data1 and want to drop observations where month larger than t, and save the new data as data2.

 

How shall I do this?

 

Thanks 

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

Please provide a sample data of the variables you have with values. This will help to get better responses. Without the data it is very difficult to suggest the code.

Thanks,
Jag
Shmuel
Garnet | Level 18

Is January 2017 greater then December 2016 ?

Are you comparing just the month or the date ?

In what format is your date? Is Character? numeric? sas date?

If it is a character date - is it ddmmyy mmddyy or any othe format ?

 

The code will change according to your answer.

The best is to post example of your data.

KachiM
Rhodochrosite | Level 12

Suppose you are interested to drop  all observations of SASHELP.CLASS where AGE = 14 to get new data as myclass.

 

data myclass;

     set sashelp.class;

     where AGE ^= 14;

run;

If you interested to drop those whose SEX = 'M' then do:

data myFemale;

    set sashelp.class;

       where Sex ^= 'M';

run;

Yavuz
Quartz | Level 8
Data data2;
Set data1;
If (month>t) then output data2;
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
  • 4 replies
  • 1145 views
  • 0 likes
  • 5 in conversation