BookmarkSubscribeRSS Feed
nenè
Calcite | Level 5
ASSET TIPEDOBVEHICLE_AGEVEHICLE COSTREG_DATESNAPSHOT_DATETERM
NEW10/09/8101500001/03/1401/04/1412
USED15/08/8661000001/09/1301/04/1412
NEW26/11/9202000001/03/1401/04/1424
USED17/02/9518500001/09/1201/04/1436

write sql procedure using dataset_initial to calculate total vehicle cost (TOT_VEH_COST) by ASSETTYPE for vehicles not older than 12.

i think that :

 

 

 

select Assettype,SUM(Vehicle_cost) as TOTAL_COST

from Initial_data

where TERM<=12

group by Assettype;

 

IS CORRECT??

3 REPLIES 3
Reeza
Super User

No, it's not correct. 

 

You're not accounting for the vehicles not older than 12 properly - mostly I think you're using the wrong variable. 

ChrisBrooks
Ammonite | Level 13

It  looks to me like reg_date is probably the correct variable to use as term is most likely the term of a loan issued to buy the vehicle.

HB
Barite | Level 11 HB
Barite | Level 11

You don't really provide enough information.

 

Vehicles not older than 12?  Is that records with a vehicle_age value of less than or equal to 12?  Or is it Term vlaues?  Or is it current date minus reg_date?  Or is it something else?

 

Let's assume a term amount <= 12.

 

So with data like

data stuff;
   input ASSET_TYPE $4. VEHICLE_COST TERM;
datalines;
NEW 15000 12
USED 10000 12
NEW 20000 24
USED 5000 36
NEW 15000 6
NEW 15000 9
USED 10000 6
;
run;

You can use the SQL you posted

proc sql;
create table cost_by_asset_type as
	select asset_type, sum(vehicle_cost)
	from stuff
	where term <=12
	group by asset_type;
quit;

 and come up with

 

ASSET_TYPE _TEMG001
NEW 45000
USED 20000

 

Is this what you want?

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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