DATA Step, Macro, Functions and more

proc report

Reply
Super Contributor
Posts: 673

proc report

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;
SAS Super FREQ
Posts: 8,862

Re: proc report

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
Ask a Question
Discussion stats
  • 1 reply
  • 135 views
  • 0 likes
  • 2 in conversation