Calcite | Level 5

## Calculate Age and filter data

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

FROM'INITIAL DATA'

WHERE TERM=36

6 REPLIES 6
Calcite | Level 5

## SAS

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 THE MEAN FOT THE DOWNPAYMENT VARIABLE BELOW?

DOWNPAYMENT

10

.

2

0

Super User

## Re: SAS

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;``````
Diamond | Level 26

## Re: SAS

Hi,

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.

Calcite | Level 5

## Re: Calculate Age and filter data

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

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.

Calcite | Level 5

## Re: Calculate Age and filter data

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

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.

Super User

## Re: Calculate Age and filter data

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.

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