Hi there,
I need to create a C language style structure that can hold heterogenous variables in it. What's the way to do it in SAS ?
Variables in SAS are numeric or character. What are you trying to do with said structure?
Hi Reeza, I want to use the struct to compare records in a different table.
Can you please explain in more detail?
There are no structure objects in SAS tables or in the SAS data step language. SAS programming is less procedural like C, but more database-like.
If you need to group variables, you might take a look at macro variables.
ie
%let struct_a = var_1 var_2 var3;
proc sort data=whatever;
by &struct_a;
run;
Maybe you could take a look at Hash Table .
I agree with @LinusH . It may be better if you could post a little bit of example start data, the desired output and business rules involved.
You may be more familiar with C but many of the approaches C users might propose are 1) almost "unnatural" for SAS and 2) may well not take advantage of SAS features.
My favorite example for comparing with other languages similar to C: You have a data set with a largish number of records and about 1000 numerical variables that you want to calculate mean, min, max, number of non-missing values. How many lines of code would you estimate to accomplish that in C?
SAS: Proc means dataset=setname; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.