For proc format issue

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

For proc format issue

I want to use Celsius in format. How can I set Superscript of O, in order to get the Celsius of "OC". Thanks.


Accepted Solutions
Solution
‎10-03-2016 09:14 AM
Grand Advisor
Posts: 10,210

Re: For proc format issue

Please see this for an example using Escapechar and UNICODE function.

ods escapechar='^';
proc format library=work;
picture degreeC low-high="0009.00" "^{unicode '00B0'x}C";
run;

data junk;
   x=27;
run;

proc print data=junk;
   format x degreeC.;
run;

This is likely only to work for destinations that support Unicode in some way such as HTML, PDF or RTF. Note that the code is a Degree symbol, not a superscript 'O', so is likely to be more font proof.

 

View solution in original post


All Replies
Respected Advisor
Posts: 4,972

Re: For proc format issue

The answer can vary from one printer to the next. 

 

The most likely workable approach would be to find a font on your printer that contains a degree sign.  Find the codes (in the printer manual, most likely) that switch to that font, and then the code that switches back to the previous font.  

 

Alternatively, you may want to just settle for a lowercase "o" instead of a degree symbol.  Still, you need to know what code your printer uses as a superscript and what code it uses as a subscript.

 

Once you have a set of codes, you would need to plug them into a picture format.  Either way, it's not pretty, but it's workable.

Contributor
Posts: 66

Re: For proc format issue

For a simple example:

 

data a;
input abc;
datalines;
1
2
3
;


proc format;
value abc
1="temperture (OC)"
2="Height (cm)"
3="Weight (Kg)";
run;

 

proc print data=a;
var abc;
format abc abc.;
run;

 

 

How can I get Superscript "O" for "OC"?

Respected Advisor
Posts: 4,972

Re: For proc format issue

Do you know for certain whether your printer is able to do that?

 

You might start by finding every character that your printer can print using your current font, along these lines:

 

data _null_;

do i=0 to 255;

   char = byte(i);

   put i= char=;

end;

run;

 

I think BYTE is the simplest way to approach this, but haven't used it much.  When you examine the log, you will see the possibilities.  

 

Complications:  Sometimes the window-displayed version of CHAR= will be different than the printed version.  Also, sometimes a CHAR value carries different meaning when sent to the printer such as "skip a line" or "start a new page" or even "turn the printer off".

Solution
‎10-03-2016 09:14 AM
Grand Advisor
Posts: 10,210

Re: For proc format issue

Please see this for an example using Escapechar and UNICODE function.

ods escapechar='^';
proc format library=work;
picture degreeC low-high="0009.00" "^{unicode '00B0'x}C";
run;

data junk;
   x=27;
run;

proc print data=junk;
   format x degreeC.;
run;

This is likely only to work for destinations that support Unicode in some way such as HTML, PDF or RTF. Note that the code is a Degree symbol, not a superscript 'O', so is likely to be more font proof.

 

Contributor
Posts: 66

Re: For proc format issue

Thanks. Got it.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 382 views
  • 1 like
  • 3 in conversation