BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dyan
Calcite | Level 5

Hi

I am trying to produce a table template for a report. One column of table need to add superscript to the cell according to the cell value ( for example, if the value >1 then a super a need to add to that value). it seems that cellstyle and translate don't work. Does anyone can help on this quesitons.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Ou? Sorry. I don't notice this.

Just use picture format to replace numeric format. No problem.

proc format;
picture rf(default=40)
       low-1="9.999"
       1<-high="9.99 ~{super b}";
run;

data one;
input name :$40. age ratio;
if age lt 20 then name=catx(' ',name,'~{super a}');
format ratio rf.;
cards;
Mathew  14  0.75
Mark 15 0.975
Luck  37 12.59
John 48   2.75
Paul 45  0.735
;
run;
ods rtf file="c:\x.rtf";
ods escapechar="~"; 
proc report data=one nowd ;
run;
ods rtf close; 

Ksharp

View solution in original post

7 REPLIES 7
art297
Opal | Level 21

Possibly the following paper might help: http://www.lexjansen.com/pharmasug/2007/po/po12.pdf

It uses a compute block to assign superscripts based on cell values.

dyan
Calcite | Level 5

the paper is useful for fixed string, but how about on the dynamic value? ( it seems the proc format

could do the trick, but I have not made it work on my data)

art297
Opal | Level 21

Can you post some example data (perferably in the form of a datastep) and the code you tried?

dyan
Calcite | Level 5

data one;

input name$ age ratio;

cards;

Mathew  14  0.75

Mark 15 0.975

Luck  37 12.59

John 48   2.75

Paul 45  0.735

;

I would like add superscript "a" on the name whose age is less than 20 and add superscipt "b" on the number in ratio column that greater than 1.

ods rft file="c:\output\rtf"

ods escapechar="^";

proc format;

picture ratioform

low-1.0="9.999"

1.0-high="9.99^{super b}";/* I did not make this work, it add super b, but the decimal point is wrong*/

run;

proc template;

define table mytable;

     column name age ratio;

               /****need help on name super a*/

     define column ratio;

          header ="Ratio";

          format=ratioform.

     end;

end;

data _null_;

set one;

file print ods=(template="mytable");

put _ods_;

run;

ods rtf close;

Ksharp
Super User

I tested it . No problem.

You should use numeric format not picture format.

proc format;
value rf(default=40)
       low-1="9.999"
       1<-high="9.99 ~{super b}";
run;

data one;
input name :$40. age ratio;
name=ifc(age lt 20,catx(' ',name,'~{super a}'),name);
format ratio rf.;
cards;
Mathew  14  0.75
Mark 15 0.975
Luck  37 12.59
John 48   2.75
Paul 45  0.735
;
run;
ods rtf file="c:\x.rtf";
ods escapechar="~"; 
proc report data=one nowd ;
run;
ods rtf close; 

Ksharp

dyan
Calcite | Level 5

Thank you, Ksharp. Your code is really helpful. The numeric format does not work for me because I want to add super b to 12.59  ( it should be 12.59 {super b} not 9.99{super b}. The picture format works fine this time. But the name {super a } works cool!!! and I learned a funcion IFC.  

Again, thank you very much!

Ksharp
Super User

Ou? Sorry. I don't notice this.

Just use picture format to replace numeric format. No problem.

proc format;
picture rf(default=40)
       low-1="9.999"
       1<-high="9.99 ~{super b}";
run;

data one;
input name :$40. age ratio;
if age lt 20 then name=catx(' ',name,'~{super a}');
format ratio rf.;
cards;
Mathew  14  0.75
Mark 15 0.975
Luck  37 12.59
John 48   2.75
Paul 45  0.735
;
run;
ods rtf file="c:\x.rtf";
ods escapechar="~"; 
proc report data=one nowd ;
run;
ods rtf close; 

Ksharp

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