BookmarkSubscribeRSS Feed
angeliquec
Quartz | Level 8

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
jakarman
Barite | Level 11

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 --<-----
angeliquec
Quartz | Level 8

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.

jakarman
Barite | Level 11

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;


---->-- ja karman --<-----

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 5819 views
  • 4 likes
  • 2 in conversation