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 |
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 |
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.
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 .
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.
how should i separate vehicle data as i only want vehicle type=passenger ?
@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
Do you have a vehicle type field in your data that you haven't shown us?
Yes i am having
Manufacturer | Model | Latest Launch | Vehicle type | |
Acura | Integra | 2-Feb-14 | Passenger | |
Acura | TL | 22-Dec-15 | Passenger | |
Acura | CL | 23-Oct-15 | Passenger | |
Acura | RL | 5-Dec-14 | Passenger | |
Dodge | Ram Pickup | 9-Nov-15 | Passenger | |
Dodge | Ram Wagon | 13-Apr-14 | Passenger | |
Dodge | Ram Van | 18-Apr-14 | Car | |
Dodge | Dakota | 16-Jan-14 | Car | |
Dodge | Durango | 17-Nov-15 | Car | |
Dodge | Caravan | 6-Jun-14 | Car | |
Buick | Park Avenue | 11-Feb-15 | Passenger | |
Buick | LeSabre | 9-Mar-15 | Passenger | |
Cadillac | DeVille | 23-Mar-14 | Passenger | |
Cadillac | Seville | 23-Jul-15 | Passenger | |
Cadillac | DeVille | 23-Feb-14 | Passenger | |
Cadillac | Seville | 29-Apr-15 | Passenger |
separate out the passenger vehicles data launched after 20 april 14
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 |
Thanks a lot 🙂
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.
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.