BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DmytroYermak
Lapis Lazuli | Level 10

Hi all,

 

I have some '0' values in my table. When I put it in character format :

 

 

put (x,best.)

 

 

and then list in the table using Proc Report:

 

 

define var2 / " Column_name " style(header)=[cellwidth=10.5%] style(column)=[just=d posttext='    '] ;

I receive the following issue:

 

The column where I have just zero values and values without decimal are shifted right ( I marked green the line that should be shifted left ). I think that put '0' in the view' '0.000' will be enough to align the figures to the center. Have you ever faced the issue and what could be a solution for the case?

 

2.jpg

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
DmytroYermak
Lapis Lazuli | Level 10

The solution was offered by one kind colleague:

 

define var2 / "Cohort XXXX" style(header)=[cellwidth=11.5%] style(column)=[just=c protectspecialchars=off pretext="\qj\tqdec\tx800 "] ;

Thus special 'report' code was used:

[just=c protectspecialchars=off pretext="\qj\tqdec\tx800 "] 

where 800 can vary to shift the text. It is important to keep space after 800. 

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20
Well put using a different format, like 4.2 or 5.3.
Even though I'm a bit allergic about storing continues numerical values as strings, buti assume that you have very specific display requirements.
Data never sleeps
ballardw
Super User

Are you attempting to align decimal points in character values? I don't think that is what the decimal align expects.

 

Also creating a character value with Put can create leading spaces which are significant when it comes to attempting to align anything.

 

Please look at this code:

data junk;
   x=0;
   y1= quote( put(x,best.) );
   y2= quote( put(x,best3.) );
   y3= quote( put(x,best5.) );
   y4= quote( put(x,best. -L) );
run;

The quotes in the various Y values are to outline the resulting blanks in the created variable. Any format length longer than the value needs, except the Z format for leading 0's, will create leading blanks unless the -L option (to left justify the result) on the Put function is used.

 

DmytroYermak
Lapis Lazuli | Level 10

The solution was offered by one kind colleague:

 

define var2 / "Cohort XXXX" style(header)=[cellwidth=11.5%] style(column)=[just=c protectspecialchars=off pretext="\qj\tqdec\tx800 "] ;

Thus special 'report' code was used:

[just=c protectspecialchars=off pretext="\qj\tqdec\tx800 "] 

where 800 can vary to shift the text. It is important to keep space after 800. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4999 views
  • 1 like
  • 3 in conversation