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.
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?
if terrid ne '' then hold=terrid;
if terrid eq '' then terrid=hold;
if bsm ne '' then hold1=bsm;
if bsm eq '' then bsm=hold1;
if region ne '' then hold3=region;
if region eq '' then region=hold3;
compute md_zip ;
if md_zip ne '' then hold4=md_zip ;
if md_zip eq '' then md_zip =hold4;
if physician_name ne '' then hold5=physician_name ;
if physician_name eq '' then physician_name =hold5;
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:
compute before physician_name;
hold5 = ' ';