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

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?  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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:

interpunct.png

 

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

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

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:

interpunct.png

 

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

GoBlue88
Calcite | Level 5

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!

 

ballardw
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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