BookmarkSubscribeRSS Feed
K_HARI_PRASAD
Calcite | Level 5

Hi,

I have a string, Let it be 'GOOD'. Now I want to create a array with the length of the string i.e 4(here length of the string GOOD is 4). And I want to take each character of GOOD into each array element and I want to concatenate all the four array elements. Finally the result would be GOOD only.

3 REPLIES 3
K_HARI_PRASAD
Calcite | Level 5

Here the length may vary each time that is instead of GOOD i may pass THIS IS SAS

data_null__
Jade | Level 19

In SAS arrays have fixed length defined when the code is compiled.  The associative array (hash) is a dynamic sized object so you may consider that option.

However I don't see the point of your question.  State the problem again in more detail.

While you do that you may consider this bit

data test;
   input string $char20.;
  
array c[20] $1;
  
call pokelong(string,addrlong(c[1]),length(string));
   *CALL POKELONG(source,pointer<,length><,floating-point> );
  
cards;
GOOD
i may pass
THIS IS SAS
;;;;
   run;
proc print;
  
run;
ballardw
Super User

Provide some input/output examples.

Pulling individual characters and then concatenating them back to a string really sounds like you may be needing one of Strip, Compress or some other string function instead.

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