BookmarkSubscribeRSS Feed
santhosh
Fluorite | Level 6

i need to justify aliment of the columns

data test;

input ID $ 1-5 NAME $ 6-17 REMARKS $ 18-35;

datalines;

1121 Tom Carry     Not attended demo

1122 Nancy Peter Out of town     

1123 Smith           attended demo   

1124 John perera   holiday on demo 

;

run;

proc report data=test nowd;

run;

as name and remarks are left aligned i want full justify alligment as shown

ID      Name           Remarks

1121 Tom    Carry  Not attended demo

1122 Nancy Peter Out      of        town     

1123 Smith           attended        demo   

1124 John perera   holiday   on   demo 

is it possible

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Read up on the proc report section as its quite big.  Something like:

proc report data=test nowd;

     define ID / "ID" style(column)=[j=c];

     define Name / "Name" style(header)=[j=r] style(column)=[j=r];

run;

santhosh
Fluorite | Level 6

I am getting error any way

i dont want any thing right or center i want all columns to be justified as in word u have option justify

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please elaborate, what error are you getting?  The word is actually just= (not j=) with the options l=left, r=right, c=centered.

Do you mean centered, then change to just=c.

Ksharp
Super User

What destination are you using ? SAS has no such align style like word .

Here is an example for PDF destionation.

data have;
infile cards length=len;
input str $varying200. len;
cards;
China adheres to the principle
I can't abide to see
As the branch
Abide in Me, and I in you
;
run;
proc sql noprint;
select max(length(str)) into : max from have;
quit;
%put &max ;
data want(keep=str new_str);
 set have;
 length new_str $ 200 ;
 blanks=countc(strip(str),' ') + ( &max - length(str));
 c=countw(str,' ');
 l=int(divide(blanks,c-1));
 r=blanks-l*(c-1)+1;
 do i=1 to c;
  if i le r  then new_str=catx(repeat(' ',l),new_str,scan(str,i,' '));
   else new_str=catx(repeat(' ',l-1),new_str,scan(str,i,' '));
 end;
run;
ods listing close;
ods pdf file='c:\temp\x.pdf' ;
proc print noobs;run;
ods pdf close;
ods listing;


Xia Keshan

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