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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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