BookmarkSubscribeRSS Feed
steve_citi
Calcite | Level 5
Can't figure out why the retain statement will not hold the value of holdbroke or brokefound.
Can someone explain why?

The idea of the code is to capture the month when delbnd is greater than or equal to 3, and place it on ever subsequent record for the customer.


data forbearance3;
retain holdbroke;
retain brokefound 0;
holdbroke=.;
set forbearance2;
by cust_no asofmonth;
if first.cust_no then do; brokefound=0; conbrokemon=.; end;

if brokefound=0 then do;
if delbnd>=3 then do;
holdbroke=asofmonth;
brokefound=1;
end;
else;

end;

if brokefound=1 then do;
conbrokemon=holdbroke;
end;
run;
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You have code that assigns a missing value with every DATA step pass. Suggest you might want to add this line of code for self-debugging and some desk-checking of your program (add multiple occurences and assign unique nn to keep track where your program is generating the diagnostic messages to the SAS log):

PUTLOG '>DIAG-nn' / _ALL_;


Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic/post:

data step programming retain statement site:sas.com
steve_citi
Calcite | Level 5
Thanks. To be honest, even though I've been looking at the code, trying to figure the problem out, I did not even notice that statement was still there!!
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Using the PUTLOG (new with SAS v9, previously used PUT with FILE LOG;) will help with the condition - it helps me all the time and I've been using SAS for 25+ years.

Scott

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 744 views
  • 0 likes
  • 2 in conversation