BookmarkSubscribeRSS Feed
AUTigers
Calcite | Level 5

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

2 REPLIES 2
art297
Opal | Level 21

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.

Tom
Super User Tom
Super User

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-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
  • 925 views
  • 0 likes
  • 3 in conversation