BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mmagnuson
Quartz | Level 8

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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;

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1297 views
  • 0 likes
  • 2 in conversation