BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
The variables in the compute block are grouped in the define statements in proc report.
For physician_name the name from previous record is being populated.
ex:
Stephan Kirk belong to terrid "1234".
and the physician record for terrid "1235" is blank which is correct.
But using the compute block Stephen kirk is being populated in "1235".
How to avoid this?

compute terrid;
if terrid ne '' then hold=terrid;
if terrid eq '' then terrid=hold;
endcomp;
compute bsm;
if bsm ne '' then hold1=bsm;
if bsm eq '' then bsm=hold1;
endcomp;
compute region;
if region ne '' then hold3=region;
if region eq '' then region=hold3;
endcomp;
compute md_zip ;
if md_zip ne '' then hold4=md_zip ;
if md_zip eq '' then md_zip =hold4;
endcomp;
compute physician_name;
if physician_name ne '' then hold5=physician_name ;
if physician_name eq '' then physician_name =hold5;
endcomp;
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
Without seeing the entire program it is hard to know -exactly- what is going on. However, in general, PROC REPORT process report items in this fashion:
-- Report item appears on the COLUMN statement (this could be a data set variable, a statistic or a computed item)
Every report row is initialized to missing at the start of the report row. This means that items which appear in a COLUMN statement are automatically initiallized at the start of every report row.

--Temporary report variables do NOT appear in the COLUMN statement-- this means that you are probably ONLY using these variables in COMPUTE blocks.
Temporary report variable values (possibly like HOLD, HOLD1, etc) are automatically retained. It is your responsibility to figure out when the variable value needs to be reset. Frequently, this is done by testing the use of the _BREAK_ automatic variable or done in a COMPUTE before block:
[pre]
compute before physician_name;
hold5=physician_name;
**OR;
hold5 = ' ';
endcomp;
[/pre]


For more information about how the REPORT procedure works, refer to these documentation topics and papers:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473631.htm (specifically the section entitled "Building a Report That Uses Temporary Variables")
http://www2.sas.com/proceedings/sugi31/060-31.pdf
http://www2.sas.com/proceedings/forum2007/242-2007.pdf


cynthia

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
  • 1 reply
  • 677 views
  • 0 likes
  • 2 in conversation