BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

In  my data I need to concatenate four variables. The output should have all values aligned in all rows to display in table. Please suggest. Thank you

output needed;

31(25) 37(14) 80.6 8.3

11(2)   12(7)   37.8 8.2

 

output getting

31(25) 37(14) 80.6 8.3

11(2) 12(7) 37.8 8.2

    data hav;
           input c1 $1-6 c2 $8-13 r1 $15-18 r2 $21-23 ;
           datalines;
31(25) 37(14) 80.6 58.3
11(2)  12(7)  37.8 18.2
           ;
           
           data want;
           set hav;
           tot=c1||"    "||c2||"    "||r1||"    "||r2;
           run;
2 REPLIES 2
Tom
Super User Tom
Super User

How are you printing the output?  If you use a proportional font then the spaces will use less width then the digits or other characters.

ballardw
Super User

Alignment is one of the reasons I do not create variables containing multiple values. With a separate variable I can use style overrides and custom formats to display columns in a tabular report, such as from Proc Report or Tabulate that aligns and appears to be single values to people without causing all the headaches of data maintenance that such composite valued variables can cause.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 357 views
  • 0 likes
  • 3 in conversation