BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rajat1
Fluorite | Level 6

I just want to separate out the  passenger vehicles data launched after 20 april 14 .

sample dataset:-

 

Manufacturer Model   Latest Launch
Acura         Integra           2-Feb-14
Acura         TL                  22-Dec-15
Acura         CL                  23-Oct-15
Acura         RL                  5-Dec-14
Dodge         Ram Pickup          9-Nov-15
Dodge         Ram Wagon           13-Apr-14
Dodge         Ram Van             18-Apr-14
Dodge         Dakota              16-Jan-14
Dodge         Durango             17-Nov-15
Dodge         Caravan             6-Jun-14
Buick         Park Avenue         11-Feb-15
Buick         LeSabre             9-Mar-15
Cadillac      DeVille             23-Mar-14
Cadillac      Seville             23-Jul-15
Cadillac      DeVille             23-Feb-14
Cadillac      Seville             29-Apr-15
1 ACCEPTED SOLUTION

Accepted Solutions
HB
Barite | Level 11 HB
Barite | Level 11
data cars;
	input 
	@1 manufacturer $8.
	@10 model $11. 
	@22 launch ddmmyy10.
	@33 type $;
	datalines;
Acura    Integra     02/02/2014 car
Acura    TL          22/12/2015 car
Acura    CL          23/10/2015 car
Acura    RL          05/12/2014 car
Dodge    Ram Pickup  09/11/2015 truck
Dodge    Ram Wagon   13/04/2014 wagon
Dodge    Ram Van     18/04/2014 van
Dodge    Dakota      16/01/2014 truck
Dodge    Durango     17/11/2015 truck
Dodge    Caravan     06/06/2014 car
Buick    LeSabre     09/03/2015 car
Buick    Park Avenue 11/02/2015 car
Cadillac DeVille     23/03/2014 car
Cadillac Seville     23/07/2015 car
Cadillac DeVille     23/02/2014 car
Cadillac Seville     29/04/2015 car
;
run;

*select cars after apr 20 2014;
data cars_after_april_20_2014;
	set cars;
	if launch > '20/Apr/2014'd;
	if type = 'car';
run;

Gives you

The SAS System      
       
manufacturer model launch type
Acura TL 20444 car
Acura CL 20384 car
Acura RL 20062 car
Dodge Caravan 19880 car
Buick LeSabre 20156 car
Buick Park Avenue 20130 car
Cadillac Seville 20292 car
Cadillac Seville 20207 car

View solution in original post

10 REPLIES 10
Reeza
Super User

What's the type and format on the DATE variable?

Is there something you've tried that doesn't work? If so, post the code and log please.

rajat1
Fluorite | Level 6

Basically i am able to understand what i have to do in this question .

How should i separate the  vehicles type as i  only need passenger data .

Reeza
Super User

Assuming you want to filter on date, you need to specify your date as the date9 format, with quotes and a D

 

where date > '01Jan2017'd;

This assumes your data has a numeric variable with a date format. Otherwise this does not apply.

 

This is a guess, because your question is unclear. If you want further help you need to take the time to detail your question.

rajat1
Fluorite | Level 6

how should i separate vehicle data as i only want vehicle type=passenger ?

Reeza
Super User

@rajat1 wrote:

how should i separate vehicle data as i only want vehicle type=passenger ?


There's nothing shown in your sample above that would allow for that type of filtering.

 

This tutorial can help you learn how to filter your data

http://video.sas.com/detail/videos/sas-analytics-u/video/4573016761001/filtering-a-sas-table-in-a-da...

HB
Barite | Level 11 HB
Barite | Level 11

Do you have a vehicle type field in your data that you haven't shown us?

rajat1
Fluorite | Level 6

Yes i am having

 

ManufacturerModelLatest LaunchVehicle type
Acura        Integra          2-Feb-14Passenger
Acura        TL               22-Dec-15Passenger
Acura        CL               23-Oct-15Passenger
Acura        RL               5-Dec-14Passenger
Dodge        Ram Pickup       9-Nov-15Passenger
Dodge        Ram Wagon        13-Apr-14Passenger
Dodge        Ram Van          18-Apr-14Car 
Dodge        Dakota           16-Jan-14Car 
Dodge        Durango          17-Nov-15Car 
Dodge        Caravan          6-Jun-14Car 
Buick        Park Avenue      11-Feb-15Passenger
Buick        LeSabre          9-Mar-15Passenger
Cadillac     DeVille          23-Mar-14Passenger
Cadillac     Seville          23-Jul-15Passenger
Cadillac     DeVille          23-Feb-14Passenger
Cadillac     Seville          29-Apr-15Passenger
rajat1
Fluorite | Level 6

separate out the  passenger vehicles data launched after 20 april 14

 

HB
Barite | Level 11 HB
Barite | Level 11
data cars;
	input 
	@1 manufacturer $8.
	@10 model $11. 
	@22 launch ddmmyy10.
	@33 type $;
	datalines;
Acura    Integra     02/02/2014 car
Acura    TL          22/12/2015 car
Acura    CL          23/10/2015 car
Acura    RL          05/12/2014 car
Dodge    Ram Pickup  09/11/2015 truck
Dodge    Ram Wagon   13/04/2014 wagon
Dodge    Ram Van     18/04/2014 van
Dodge    Dakota      16/01/2014 truck
Dodge    Durango     17/11/2015 truck
Dodge    Caravan     06/06/2014 car
Buick    LeSabre     09/03/2015 car
Buick    Park Avenue 11/02/2015 car
Cadillac DeVille     23/03/2014 car
Cadillac Seville     23/07/2015 car
Cadillac DeVille     23/02/2014 car
Cadillac Seville     29/04/2015 car
;
run;

*select cars after apr 20 2014;
data cars_after_april_20_2014;
	set cars;
	if launch > '20/Apr/2014'd;
	if type = 'car';
run;

Gives you

The SAS System      
       
manufacturer model launch type
Acura TL 20444 car
Acura CL 20384 car
Acura RL 20062 car
Dodge Caravan 19880 car
Buick LeSabre 20156 car
Buick Park Avenue 20130 car
Cadillac Seville 20292 car
Cadillac Seville 20207 car
rajat1
Fluorite | Level 6

Thanks a lot 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 30057 views
  • 2 likes
  • 3 in conversation