BookmarkSubscribeRSS Feed
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Hello all;
I am trying to format a single row apart from the others so that the calculated (CRBSI) rate has two decimal points in a 5.2 format while all other rows have a standard 5. format;
Been playing around with it, but to no avail...
The code:

format bwcat1-bwcat6 total 5.;
if _label_ ='CRBSI RATE' THEN DO;
format bwcat1-bwcat6 total 5.2 ;
End;

I understand what it is doing-when the variable name matches the if statement it reverts all the rows to the new format...I just don't how to specify...

Much thanks...

Lawrence
5 REPLIES 5
LinusH
Tourmaline | Level 20
The format statement is "global" for variables in the whole table, and a format cannot be assigned based on a row basis in table. Is _label_ a user defined variable? (showing your whole code make it easier for us to help you). If you like to set a certain format conditionally on the table level, you can use macro programming.

Regards,
Linus
Data never sleeps
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Linus;
I figured as much as to the fact that format is a "global statement"
_LABEL_ is generated as a byproduct of a proc transpose...
The whole code is quite lengthy and it is only this part that is causing a small obstacle.

I will take a stab at writing a macro perhaps...
Thank you for the clarity on this issue...

Lawrence
Cynthia_sas
SAS Super FREQ
Hi:
I think a macro approach would not be required, when PROC REPORT can do this easily for reporting purposes.

As far as the data set descriptor goes, the same format has to be applied to the same numeric column -- unless you turn the numeric variable into a character variable using the PUT function and different formats.

cynthia
[pre]
ods listing;
options nodate nonumber;
proc report data=sashelp.class nowd;
column name age height;
define name / order;
define age / f=8.0;
define height / f=8.0;
compute age;
if name = 'Barbara' then do;
call define (_col_,'format','8.3');
end;
else if name = 'John' then do;
call define (_col_,'format','8.5');
end;
endcomp;
compute height;
if name = 'Barbara' then do;
call define (_col_,'format','8.3');
end;
else if name = 'John' then do;
call define (_col_,'format','8.5');
end;
endcomp;
run;
[/pre]
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Cynthia;
Will certaintly give this a try!
Thank you!
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Cynthia;
Worked like a charm!
Thank you!

Lawrence

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 645 views
  • 0 likes
  • 3 in conversation