- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am not new to PROC REPORT, but I cannot seem to get this to work for some reason. Can someone help me see where I am missing something?
The code below is extrememly simplified from what I have in practice (I actually have 35+ variables between SUBJID and STATUS). But in short, I only want to highlight these 2 variables if an additional variable (NEW) is flagged even though I do not want NEW to appear in the output. I know that a compute block will only look at variables to the left, so I put NEW at the very end to ensure that all variables are previously defined. Still, when I run this code, I get a note in the log that NEW is uninitialized, and no highlighting occurrs. Can someone tell me if I am doing something wrong?
proc sql;
create table final (SUBJID char(11), STATUS char(15), new num);
insert into final (subjid, status, new)
values ('101-136-001','Screen Failed',.)
values ('101-136-002','Screen Failed',1)
values ('101-136-003','Screened',.)
values ('101-136-004','Randomized',.)
values ('101-136-005','Genotyped',1)
values ('101-136-006','Screened',.);
quit;
proc report data=final;
column SUBJID STATUS NEW;
define subjid / 'Subject Number';
define status / 'Status';
define new / noprint;
compute new;
if new=1 then do;
call define('subjid',"style","style={background=cx00B0F0}");
call define('status',"style","style={background=cx00B0F0}");
end;
endcomp;
run;
SAS LOG:
5743 proc sql;
5744 create table final (SUBJID char(11), STATUS char(15), new num);
NOTE: Table WORK.FINAL created, with 0 rows and 3 columns.
5745 insert into final (subjid, status, new)
5746 values ('101-136-001','Screen Failed',.)
5747 values ('101-136-002','Screen Failed',1)
5748 values ('101-136-003','Screened',.)
5749 values ('101-136-004','Randomized',.)
5750 values ('101-136-005','Genotyped',1)
5751 values ('101-136-006','Screened',.);
NOTE: 6 rows were inserted into WORK.FINAL.
5752 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
5753
5754 proc report data=final;
5755 column SUBJID STATUS NEW;
5756 define subjid / 'Subject Number';
5757 define status / 'Status';
5758 define new / noprint;
5759 compute new;
5760 if new=1 then do;
5761 call define('subjid',"style","style={background=cx00B0F0}");
5762 call define('status',"style","style={background=cx00B0F0}");
5763 end;
5764 endcomp;
5765 run;
NOTE: Variable new is uninitialized.
NOTE: There were 6 observations read from the data set WORK.FINAL.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this
define new / display noprint;
Also, from now on, please show us the ENTIRE log for the PROC (or data step) that has the error. Do not pick and choose parts of the log of that PROC (or data step) to show us. Do not separate the errors from the code (as seen in the log) that produced them.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this
define new / display noprint;
Also, from now on, please show us the ENTIRE log for the PROC (or data step) that has the error. Do not pick and choose parts of the log of that PROC (or data step) to show us. Do not separate the errors from the code (as seen in the log) that produced them.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The default type for numeric variables is ANALYSIS. You could have used NEW.SUM in the COMPUTE block.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@djbateman wrote:
Also, that was the entire log. I left nothing out. Just 3 simple notes.
@djbateman I disagree. The entire log shows code, beginning with the PROC REPORT statement and it continues down until the last NOTE after the end of the procedure. That's what we need from now on, the ENTIRE log for the PROC (or data step) including code, with nothing chopped out. Separating the ERROR messages from the code that created it is counter-productive, and doesn't let us clearly understand the errors in most cases (and although it does not matter in this specific example, it does matter and is critical in many other situations).
Paige Miller