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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 7 replies
  • 1199 views
  • 1 like
  • 6 in conversation