DATA Step, Macro, Functions and more

C style structures

Reply
Occasional Contributor
Posts: 19

C style structures

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 ?

Super User
Posts: 19,785

Re: C style structures

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

Occasional Contributor
Posts: 19

Re: C style structures

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

Super User
Posts: 19,785

Re: C style structures

Can you please explain in more detail?

Super User
Posts: 7,771

Re: C style structures

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,023

Re: C style structures

Maybe you could take a look at Hash Table .

Super User
Posts: 5,426

Re: C style structures

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
Super User
Posts: 11,343

Re: C style structures

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;

 

Ask a Question
Discussion stats
  • 7 replies
  • 313 views
  • 1 like
  • 6 in conversation