BookmarkSubscribeRSS Feed
KrisNori
Obsidian | Level 7

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 ?

7 REPLIES 7
Reeza
Super User

Variables in SAS are numeric or character. What are you trying to do with said structure?

KrisNori
Obsidian | Level 7

Hi Reeza, I want to use the struct to compare records in a different table.

Reeza
Super User

Can you please explain in more detail?

Kurt_Bremser
Super User

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;
Ksharp
Super User

Maybe you could take a look at Hash Table .

LinusH
Tourmaline | Level 20
In the SCL programming language you could build list object structures that can be compared. That's available within the AF module.

But may I ask what you are trying to achieve? What kind if data do you have, and why do you wish to use SAS for this particular case?
Data never sleeps
ballardw
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1612 views
  • 1 like
  • 6 in conversation