BookmarkSubscribeRSS Feed
nenè
Calcite | Level 5

Hi to all,

i have a problem with this:

The dataset initial is below:

ASSET TIPE DOB VEHICLE_AGE VEHICLE COST REG_DATE SNAPSHOT_DATE TERM
NEW 10/09/81 0 15000 01/03/14 01/04/14 12
USED 15/08/86 6 10000 01/09/13 01/04/14 12
NEW 26/11/92 0 20000 01/03/14 01/04/14 24
USED 17/02/95 18 5000 01/09/12 01/04/14 36

 

 

CAN YOU TELL ME WHAT IS A SAS DATASTEP WHICH CAN BE USED TO FIND THE AGE (IN WHOLE YEARS) FOR THE CUSTOMERS OF THE NEW VEHICLES AS AT SNAPSHOT_DATE.?

AND WHAT IS A SAS DATASTEP CAN BE USED TO FIND THE CONTRACT END DATE OF THE VEHICLE WITH TERM =36, ASSUMING THE VEHICLE WAS PURCHASED ON THE SNAPSHOT_DATE?

 

I THINK THAT THE CORRECT ANSWER IS: 

SELECT

ADD_MONTHS(SNAPSHOTDATE,36)

FROM'INITIAL DATA'

WHERE TERM=36

6 REPLIES 6
nenè
Calcite | Level 5

Hi to all,

i have a problem with this:

The dataset initial is below:

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

 

 

CAN YOU TELL ME WHAT IS THE MEAN FOT THE DOWNPAYMENT VARIABLE BELOW?

 

DOWNPAYMENT

10

.

2

0

 

PeterClemmensen
Tourmaline | Level 20

I dont see the DOWNPAYMENT variable in the initial data set?

 

you can calculate the mean of DOWNPAYMENT like this

 

data have;
input DOWNPAYMENT;
datalines;
10
.
2
0
;

proc means data=have mean;
	var DOWNPAYMENT;
run;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

Avoid writing in capitals it is not plesant to read.  To answer your questions:
To find age, there are a number of methods, but 

yrdiff(dob,eventdt,'age')

Is probably simlest (assuming you have 9.3 or after version)

To find the record with term=36 then a:

where term=36;

Line can be added to a datastep.

 

For the code presented, no, it is not correct, there are several mistakes in it, no proc sql; / quit; being present is one, a function I do not know as 2, from shouldn't need quotes.

nenè
Calcite | Level 5

Hi to all,

i have a problem with this:

The dataset initial is below:

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

 

 

CAN YOU TELL ME WHAT IS A SAS DATASTEP WHICH CAN BE USED TO FIND THE AGE (IN WHOLE YEARS) FOR THE CUSTOMERS OF THE NEW VEHICLES AS AT SNAPSHOT_DATE.?

AND WHAT IS A SAS DATASTEP CAN BE USED TO FIND THE CONTRACT END DATE OF THE VEHICLE WITH TERM =36, ASSUMING THE VEHICLE WAS PURCHASED ON THE SNAPSHOT_DATE?

 

I THINK THAT THE CORRECT ANSWER IS: 

 

SELECT

ADD_MONTHS(SNAPSHOTDATE,36)

FROM'INITIAL DATA'

WHERE TERM=36

 

CAN YOU HELP ME PLEASE? I HAVE AN IMPORTANT EXAM BUT I DON'T KNOW WHAT IS THE CORRECT ANSWER FOR THIS QUESTION.

nenè
Calcite | Level 5

 

 

CAN YOU TELL ME WHAT IS A SAS DATASTEP WHICH CAN BE USED TO FIND THE AGE (IN WHOLE YEARS) FOR THE CUSTOMERS OF THE NEW VEHICLES AS AT SNAPSHOT_DATE.?

AND WHAT IS A SAS DATASTEP CAN BE USED TO FIND THE CONTRACT END DATE OF THE VEHICLE WITH TERM =36, ASSUMING THE VEHICLE WAS PURCHASED ON THE SNAPSHOT_DATE?

 

I THINK THAT THE CORRECT ANSWER IS: 

 

SELECT

ADD_MONTHS(SNAPSHOTDATE,36)

FROM'INITIAL DATA'

WHERE TERM=36

 

CAN YOU HELP ME PLEASE? I HAVE AN IMPORTANT EXAM BUT I DON'T KNOW WHAT IS THE CORRECT ANSWER FOR THIS QUESTION.

ballardw
Super User

Since Select as you are showing is not VALID in a DATASTEP, why do you propose that as part of a solution you are requesting for DATASTEP?

 

If your variables are SAS date valued variables with a format such as mmddyy10 then the functions YRDIF or Intck can return "age",

and the function INTNX is used to increment values:

 

data want;

   set have;

   age = intck('year',dob,snapshotdate); /* close by you need to look up more details on your own*/

   contractenddate= intnx('month',snapshotdate,36);

   format contractendate mmddyy10.

run;

 

PLEASE DO NOT SHOUT BY USING ALL CAPITAL LETTERS. AND REPEATING THE EXACT SAME POST IS NOT RESPONDING TO QUESTIONS THAT ARE DESIGNED TO HELP GET A RESPONSE TO YOUR QUESTION.

  

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1922 views
  • 0 likes
  • 4 in conversation