BookmarkSubscribeRSS Feed
JayhwanLee
Calcite | Level 5

 Data in the red circle are latitudes, and I am struggling with adding a degree symbol to every each one of them. Trying to do the job with using the format statement. 

스크린샷(58).png

9 REPLIES 9
PeterClemmensen
Tourmaline | Level 20

See if this works for you 🙂

 

proc format;
   picture deg other = '009.999°';
run;

data test;
   lat = 42.255; output;
   lat = 42.288; output;
   format lat deg.;
run;
FreelanceReinh
Jade | Level 19

Hi @JayhwanLee (and welcome to the SAS Support Communities, btw :-))

 

If some of your LAT values might be negative (southern latitudes), you should extend the definition of the picture format:

proc format;   
picture deg (round)
low - <0   = '0009.999°' (prefix='-')
0   - high = '0009.999°';
run;
Ksharp
Super User
proc fcmp outlib=work.func.math;
function fmt(x) $;
  length w $ 32;
  w=cats(' ',x,'(*ESC*){unicode FE12}');
  return (w);
endsub;
run;
proc format ;
value fmt
low-high=[fmt()];
run;
options cmplib=work.func;
proc report data=sashelp.class nowd;
format weight height fmt32.;
column _all_;
define _all_/style={cellwidth=80 just=right};
run;

x.png 

rogeralfa111
Fluorite | Level 6

how get that Celsius symbol after or between a variable

 

PaigeMiller
Diamond | Level 26

@rogeralfa111 wrote:

how get that Celsius symbol after or between a variable

 


@rogeralfa111  do not the solutions offered work for you? If not, please explain in detail (really, we need details) and show us the code you have tried.

--
Paige Miller
Ksharp
Super User
proc fcmp outlib=work.func.math;
function fmt(x) $;
  length w $ 32;
  w=cats(' ',x,'(*ESC*){unicode "2103"x}');
  return (w);
endsub;
run;
proc format ;
value fmt
low-high=[fmt()];
run;
options cmplib=work.func;
proc report data=sashelp.class nowd;
format weight height fmt32.;
column _all_;
define _all_/style={cellwidth=80 just=right};
run;

 

/*Or try this one*/
proc format ;
picture xx(default=40)
low-high='009.9 ℃';
run;

proc report data=sashelp.class nowd;
format weight height xx.;
column _all_;
define _all_/style={cellwidth=80 just=right};
run;

 

Ksharp_0-1664452739532.png

 

rogeralfa111
Fluorite | Level 6

yeah got it 

thank you for the solution

ballardw
Super User

@rogeralfa111 wrote:

how get that Celsius symbol after or between a variable

 


Custom formats are the way to go with values that you may need for calculation. Once you add some non-digit character like 'C' to an actual value you can no longer us it in arithmetic or model as a continuous variable.

Formats are the instructions SAS uses to display things for humans to read. You can have multiple formats and use the one you need at a specific time.

 

If you read the Documentation on Proc Format it currently includes an example of how to even do simple numeric conversions, such as degrees F to C at display.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 9 replies
  • 3323 views
  • 3 likes
  • 7 in conversation