BookmarkSubscribeRSS Feed
Kenmar
Calcite | Level 5

I have an ID variable that I want to be able to reverse for privacy. Say I have a list of ID's like 1234, is there an easy way to make that observation 4321?

 

2 REPLIES 2
Reeza
Super User

The reverse() function ...

https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245941.htm

If your variable is numeric convert it to character first using PUT(var, 8.)

ballardw
Super User

If you would like something a bit more obscure and not subject to the issues of one id= 123 and another 321 in your data try the various bitwise logical functions if your ID is numeric.

 

For example look at

data _null_;
   do x= 10 to 1010 by 10 ;
   y = bnot(x);
   
   z = bnot(y);
   put y= z= ;
   end;
run;

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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