Greetings. I need to format my decimal data in a SAS SGPLOT output to use the interpunct (centered dot) for the decimal point as required by a British medical journal. For example, I need "1.8" formatted to look like "1∙8 ". I can't find any SAS format or other way to do this in the documentation.
Anybody know how to do this?
Hi:
I thought the convention was to use a comma as the decimal separator, which can be easily done using the commax format. But the Unicode character for the interpunct or middle dot is 00B7, so if you make a character string out of the number and use the ODS ESCAPECHAR and Unicode function, then you can do it:
The code I used is here. CHARNUM is the variable that contains the interpunct character, so that's the one you use in the report procedure (here PROC REPORT):
data testit;
length charnum $40;
infile datalines dlm=',' dsd;
input linenum decnum;
interpunct='^{unicode 00B7}';
int = int(decnum);
dec = decnum -int;
charnum = catt(int,interpunct,scan(dec,2,'.'));
return;
datalines;
1,1.8
2,2.25
3,33.333
4,0.4444
;
run;
ods escapechar='^';
proc report data=testit;
column linenum decnum int dec charnum ;
define charnum / style(column)={just=r};
run;
Cynthia
Hi:
I thought the convention was to use a comma as the decimal separator, which can be easily done using the commax format. But the Unicode character for the interpunct or middle dot is 00B7, so if you make a character string out of the number and use the ODS ESCAPECHAR and Unicode function, then you can do it:
The code I used is here. CHARNUM is the variable that contains the interpunct character, so that's the one you use in the report procedure (here PROC REPORT):
data testit;
length charnum $40;
infile datalines dlm=',' dsd;
input linenum decnum;
interpunct='^{unicode 00B7}';
int = int(decnum);
dec = decnum -int;
charnum = catt(int,interpunct,scan(dec,2,'.'));
return;
datalines;
1,1.8
2,2.25
3,33.333
4,0.4444
;
run;
ods escapechar='^';
proc report data=testit;
column linenum decnum int dec charnum ;
define charnum / style(column)={just=r};
run;
Cynthia
Thanks! Yeah, I figured out the unicode of 00b7 right as the e-mail arrived with your solution. Wish it was the simple comma, but this particular journal wants the interpunct. Surprised there isn't a SAS format for it. Kind of a pain to have to separate the significant digits from the integer and then concatenate them.
Appreciate the help!
Since you are talking SGPLOT if your version of SAS is not pretty recent, earlier than 9.4m3 for instance, you really need to mention which one.
Also, where do you need to display the value that way? An axis? Data label? some where else? And what type of plot?
It would be a good idea to include your SGPLOT code and some sample data.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: