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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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