The SAS Output Delivery System and reporting techniques

Initializing a Character Variable

Reply
Super Contributor
Posts: 358

Initializing a Character Variable

Hi All:

This may be a rather basic question, but how do I initialize a large character variable with data?

My variable is 4000 bytes and I am writing specific values in parts of the record using the SUBSTR function. I want to pack bytes 3001 to 4000 with '0' (zeros) or some other character.

If it was a PUT statement I could use 1000*'0' and it would write 1000 zeros, but I can't use:

substr(text,3001,1000) = 1000*'0';

because that returns a missing value.

I would rather not do it manually and a DO loop sounds like a lot of processing for what I'm trying to do.
N/A
Posts: 0

Re: Initializing a Character Variable

Have you tried the REPEAT function? e.g.

substr(text,3001,1000)=repeat(‘0’,999);

This repeats the character ‘0’ 999 times making 1+999=1,000 characters altogether.
Super Contributor
Posts: 358

Re: Initializing a Character Variable

Posted in reply to deleted_user
Thanks - that seems to have done it.

Must have missed that one ....
Ask a Question
Discussion stats
  • 2 replies
  • 176 views
  • 0 likes
  • 2 in conversation