Help using Base SAS procedures

Proc for allocating scores

Reply
Occasional Contributor
Posts: 11

Proc for allocating scores

Hi ,

i have a large dataset that includes a variable which is a record of last date of deposit for clients. So you may have

Client                         Last_dep_date

A                                  27/12/2007

B                                  04/08/2007

C                                  02/04/2008

......with the earliest year being 2007 and the latest year being 2010. (Concentrating on the year only)

The task is to allocate a score based on the YEAR of Last_dep_date. So that a score of 4 is allocated to 2010 and a score of 1 is allocated to 2007 . What statements can i use and how do i compose the query.

Many thanks  

PROC Star
Posts: 7,477

Proc for allocating scores

If last_dep_date is a SAS date, why not just use:

score=year(last_dep_date)-2006;

Regular Contributor
Posts: 237

Proc for allocating scores

If I understand correctly, you just want to get the year of the Last_dep_date variable?  I would assume that you have the variable stored as a numeric variable with a date format.  If that is the case, then this code will capture just the year:

data

deposit;

input client $ Last_dep_date DDMMYY8.

;

format last_dep-date ddmmyy8.

;

datalines

;

A 27/12/07

B 04/08/07

C 02/04/08

;

run

;

data deposit;

set

deposit;

year=year(last_dep_date);

run

;

If your last_dep_date variable happens to be character, then you can use scan(last_dep_date,3,'/').  This means to treat the date variable as though it is 3 "words" separated by a "/" and you want to keep the 3rd "word" (or the year).

Ask a Question
Discussion stats
  • 2 replies
  • 124 views
  • 0 likes
  • 3 in conversation