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.
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;
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;
@FreelanceReinh Good catch 🙂
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;
how get that Celsius symbol after or between a variable
@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.
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;
yeah got it
thank you for the solution
@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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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: