Hi, I would like to ask how to left-align a numeric field without converting it to character? The LEFT function automatically converts the field to character. The numeric attribute of the field should be maintained as the dataset would be exported to Excel, and the numbers would be used for additional computations of the Excel users.
Your question is impossible to solve. Numerics are in a binary format, see: https://support.sas.com/techsup/technote/ts654.pdf
When you see decimal numbers they are converted to char by some function. Formats are there for this purpose.
the put function SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition is using a format for that conversion and is supporting justify (L C R)
Thank you for the response. However, I have found this proc report code which should align the variables. It doesn't work. Here is this code:
proc report data=sashelp.cars out=cars;
where make = "Acura";
column make horsepower;
define make / right;
define horsepower / right;
run;
I would like to know what is wrong with the code.
For the output dataset you have your answer.
For the ODS output part, historic the printing, there are styles. See the examples supporting styles. It is possible to do traffic lights with that. http://support.sas.com/documentation/cdl/en/proc/67327/HTML/default/viewer.htm#p1sh52tpsi1nxbn1sr371...
proc report data=sashelp.cars out=cars;
where make = "Acura";
column make horsepower;
define make / style(column)=[width=12em marginleft=0];
define horsepower / style(column)=[textalign=C] ;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.