Hello,
I have records that are populated for each month of the calendar year that have a column for points. Points change per month. There is also one record per month. For example, John Smith has one record for Jan, one record for Feb, etc. I pull this report every month so the reporting month changes.
I want to freeze his points on a specific month without impacting the other people in the dataset. So if I want to freeze his results as of June then I would not want to see July, Aug, Spet, or October on the report. As of right now I used an excel doc to import names of people I wanted to do this for and have excluded months that I don't want (these months are indicated on the excel sheet). I.e. in the excel sheet i have John Smith and July 1, 2017. So I excluded based on the date but I'm unsure of how to REPLACE the JUNE month with September so that September comes through with populated data of July. I tried to use a prompt but am unsure of how to go about doing this.
Hope this makes sense!
Suppose dataset have has id, date, and points. Dataset updates has id and date.
Sort both datasets by id and date, then run
data want;
merge
have (in=a)
updates (in=b)
;
by id date;
retain save_points;
if a;
if first.id then save_points = .;
if b then save_points = points;
if save_points ne . then points = save_points;
drop save_points;
run;
Suppose dataset have has id, date, and points. Dataset updates has id and date.
Sort both datasets by id and date, then run
data want;
merge
have (in=a)
updates (in=b)
;
by id date;
retain save_points;
if a;
if first.id then save_points = .;
if b then save_points = points;
if save_points ne . then points = save_points;
drop save_points;
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.