Contributor
Posts: 21

# Set a bit in SAS for string more than 32bits

Hi,

I have a string of 0,1s upto 64bits. I am trying to set 0 bit to 1 conditionally. say for a 56bit long string, i want to set 38th bit to 1 if it was 0. i tried BLSHIFT and BOR functions. if the string length is less than 32 bits, it is fine. but it is stop working when the length of string exceeds 32 bits.

For now, I have to use multile functions to convert the bit string to a number , then add some number, then convert it back to binary representation. for example,

%let len=56;

%let Node=1;

%let Marked=%sysfunc(repeat(0,54))1;

%let marked=%sysfunc(putN(%sysevalf(2**%eval(&len.-&Node.)+%sysfunc(inputN(&Marked,binary&len.))),binary&len.));

%put >&marked<;

if BLSHIT and BOR can work with bits string more than 32. the life will be much easier.  I posted same post on SAS-L. it looks like lots fof folks from SAS-L now are hanging out here. Hope i can get some responses quickly. sorry for reposting.

does anyone know If there are any functions can do more than 32bits manipulations?

Thanks!

Yu

PROC Star
Posts: 8,163

## Set a bit in SAS for string more than 32bits

Yu,  Other than peek and poke, I don't know of any other bitwise functions that have been upgraded to cover more than 32 bit manipulations.  Paul Dorfman posts both here, and over on SAS-L, and you may have to wait for his possible response.

Super User
Posts: 8,069

## Re: Set a bit in SAS for string more than 32bits

The question does not make any sense to me.  Perhaps if you explained WHY.

There is no conditional in your question.

Here is how to set the 38th digit of a character sting of 1s and 0s to a 1.

`42   %let marked=%sysfunc(repeat(0,54))1;43   %let new=%substr(&marked,1,37)1%substr(&marked,39);44   %put &marked;0000000000000000000000000000000000000000000000000000000145   %put &new;00000000000000000000000000000000000001000000000000000001`
Discussion stats
• 2 replies
• 291 views
• 0 likes
• 3 in conversation