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
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.
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;
00000000000000000000000000000000000000000000000000000001
45 %put &new;
00000000000000000000000000000000000001000000000000000001
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.