DATA Step, Macro, Functions and more

Right align my monetary data

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Right align my monetary data

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


Accepted Solutions
Solution
‎07-01-2011 01:35 AM
Super User
Posts: 10,035

Right align my monetary data

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


All Replies
Super User
Posts: 19,822

Right align my monetary data

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

Occasional Contributor
Posts: 15

Right align my monetary data

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

Super User
Posts: 19,822

Right align my monetary data

What are you outputting it to? 

Occasional Contributor
Posts: 15

Right align my monetary data

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

Valued Guide
Posts: 2,177

Right align my monetary data

Mike018

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

peterC

Contributor
Posts: 23

Right align my monetary data

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

Solution
‎07-01-2011 01:35 AM
Super User
Posts: 10,035

Right align my monetary data

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 302 views
  • 3 likes
  • 5 in conversation