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

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