BookmarkSubscribeRSS Feed
OS2Rules
Obsidian | Level 7
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.
2 REPLIES 2
deleted_user
Not applicable
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.
OS2Rules
Obsidian | Level 7
Thanks - that seems to have done it.

Must have missed that one ....

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1810 views
  • 0 likes
  • 2 in conversation