BookmarkSubscribeRSS Feed
EinarRoed
Pyrite | Level 9

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"?

2 REPLIES 2
maguiremq
SAS Super FREQ

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;
data_null__
Jade | Level 19

Could you use CATS to do the heavy lifting?

 

data class2;
   set sashelp.class;
   length chk $256;
   chk = sha256(cats(of name--weight));
   run;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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