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
If last_dep_date is a SAS date, why not just use:
score=year(last_dep_date)-2006;
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).
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.