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 --<-----

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 3 replies
  • 4897 views
  • 4 likes
  • 2 in conversation