I have a task of encrypting group IDs using random values - either alphabet or number. I've created a format to map each of the 26 alphabets to a two digit random number, and each single digit number (0-9) to a two digit alpha-numeric random value, such that none of the values appear more than once.
Now, the question is, how do I change the 9 digits of group ID to 18 encrypted digits based on the format values?
This makes a lot of sense. In fact, I'd tried something similar though not same, trying to use put function for using user defined format. However, it is the part where I need to concatenate all substrings together that is throwing me off. Coz even if I use lag function to retain the last value of j or new_j, it will still give value for only last 2 characters, and not a combined string of all previous characters.
Suggest sharing your SAS code that is not working. Also, you likely need to look at using both a LENGTH and a RETAIN statement -- mostly the RETAIN is needed if your DATA step iterates (bottom back to the top) instead of having a DO/END loop with a SET / INPUT statement code-paragraph for data manipulation.
Suggested Google advanced search argument, this topic / post:
If your ID's are always the same length, ie 9 as in your description the following works. If not then you'll need a different solution, using retain and length statement,where you basically append the new read value onto the string after encoding it.