BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
djbateman
Lapis Lazuli | Level 10

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
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

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
djbateman
Lapis Lazuli | Level 10
ARE YOU SERIOUS? That did the trick. I knew it would be something simple that I was just not seeing. Thank you so much!
data_null__
Jade | Level 19

The default type for numeric variables is ANALYSIS.  You could have used NEW.SUM in the COMPUTE block.

djbateman
Lapis Lazuli | Level 10
Also, that was the entire log. I left nothing out. Just 3 simple notes.
PaigeMiller
Diamond | Level 26

@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

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