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.
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
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.
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)Can you post some example data (perferably in the form of a datastep) and the code you tried?
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;
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
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!
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.