BookmarkSubscribeRSS Feed
yonib
SAS Employee
Does someone can help me with this?
The first example I want to get aqqq 30qqq ageqqq sexqqq , i dont get it !!!!
but when im doing it in the oposite way i get what i want.
Does someone Knows whats my problem.

/*not working*/
data a;
input Class $ Age $ Sex $ ;
cards;
a 30 m y
b 60 y n
;
run;
data b;
set a;
array test Class Age Sex ;
do over test;
test=test||'qqqqqq';
end;
run;



/*works well*/

data a;
input Class $ Age $ Sex $ ;
cards;
a 30 m y
b 60 y n
;
run;
data b;
set a;
array test Class Age Sex ;
do over test;
test='qqqqqq'||test;
end;
run;
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
In your "not working" process, you are attempting to concatenate a data string to the end of a SAS variable. The concatenation operation does not trim trailing blanks, so your resulting SAS variable (after the array processing) has been truncated.

For what you are trying to accomplish, you must use a function to accomplish the trim, such as CATT (new with SAS 9, or TRIM -- there are others as well).

Also, if you were to add a PUT _ALL_ to your DO/END processing after the assignment, you might have some additional diagnostic information to see the execution as it is processing.

Scott Barry
SBBWorks, Inc.
yonib
SAS Employee
I got it thanks for your help!!

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