BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mike018
Fluorite | Level 6

I have some monetary data that could have diffrent length. (Ex. with a format of 10.2, I could have 1234.56 or 1234567.89)

I know that I can right align that by converting to char and add some zeros depending on the value - that's not what I want.

Actually, If I don't want all these extra zeros to appear, then the values are not right aligned.

So, how can I print the real number (with no extra zero) AND right align that.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Numeric data is right align default.

If you use a format in data _null_ to print data , the number will be right align.

data x;
input x 10.2;
cards;
1234.56
1234567.89
;run;
data _null_;
set x;
put x best10.2;
run;





Ksharp

View solution in original post

7 REPLIES 7
Reeza
Super User

If you're printing the data using proc report can you use align=right?  

Mike018
Fluorite | Level 6

Actually, I use a data _null_ . Is there a way to do it with a Data?

Reeza
Super User

What are you outputting it to? 

Mike018
Fluorite | Level 6

@Reeza : In my outfile, I put a report that contains some totals for the different types of record I read from my infile.

@rtritz : Thanks, I'll try it.

Peter_C
Rhodochrosite | Level 12

Mike018

use a format in the PUT statement in your data _null_ step.

peterC

rtritz
Calcite | Level 5

One possibility is to convert the numeric data to character and use the right function which will right align character variables in the data cell by adding blanks not zeros.

Rich

Ksharp
Super User

Numeric data is right align default.

If you use a format in data _null_ to print data , the number will be right align.

data x;
input x 10.2;
cards;
1234.56
1234567.89
;run;
data _null_;
set x;
put x best10.2;
run;





Ksharp

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 7 replies
  • 2416 views
  • 3 likes
  • 5 in conversation