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 ....

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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