Quartz | Level 8

How to left-align a numeric field?

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.

3 REPLIES 3
Barite | Level 11

Re: How to left-align a numeric field?

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)

---->-- ja karman --<-----
Quartz | Level 8

Re: How to left-align a numeric field?

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.

Barite | Level 11

Re: How to left-align a numeric field?

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;

---->-- ja karman --<-----
Discussion stats
• 3 replies
• 4897 views
• 4 likes
• 2 in conversation