I've got a table with around 50 variables. Roughly 30 numerics, and 20 chars. Need to create a checksum that's unique for all the 50 variables.
I'm currently casting the 30 numerics to character. Then I combinine all 50 char values into 1 variable that I use in SHA256 to create the actual checksum.
I'd like to make this more dynamic. So that I don't need to use 1 PUT-statement for each variable I cast from numeric to character.
I've written code that identifies all numeric variables and creates a temporary table for them. Is there a way to tell SAS to "cast all variables in this table to character"?
Can you provide some example data? One way I think off the top of my head is through an array.
Here's what I'm talking about:
data have;
input a b c d;
datalines;
1 2 3 4
;
run;
data want;
set have;
array all_num [*] _numeric_;
array all_char [*] $1. chars1 - chars4;
do i = 1 to dim(all_num);
all_char[i] = put(all_num[i], 1.);
end;
run;
Could you use CATS to do the heavy lifting?
data class2;
set sashelp.class;
length chk $256;
chk = sha256(cats(of name--weight));
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.