BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
changxuosu
Quartz | Level 8

Dear SAS community,

 

I have a question that needs your wisdom.

 

I have 30 tables, say Table1,table2,...table 30. All of them have the same data structure and the same list of variables (which includes a variable name GOOD) except that the ith  table denotes the month i.

 

Now I need to create a new table X, which is composed of two columns/variables.

 

The first variable of table X is i, the index for table i; the second variable of table X is the means of variable GOOD for table i.

 

Does any one can point me to any idea/procedure/SAS macro that achieve this?

Rather than

 

Thanks in advance!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

That's one reason to never split your data sets. You can create a view which stacks the data sets temporarily and then calculates your summary statistics. Or you can write a macro that calculates it for each data set and then appends it but that's a much more complicated task. I'd only recommend that if your data sets are too big to process as one data set. 

 

data _temp / view=_temp;
set table1-table30 indsname=mySource;
ds = mySource;
keep Good DS;
run;

proc means data=_temp noprint;
by ds NOTSORTED;
var Good;
output out=want mean=Mean_Good;
run;

View solution in original post

2 REPLIES 2
Reeza
Super User

That's one reason to never split your data sets. You can create a view which stacks the data sets temporarily and then calculates your summary statistics. Or you can write a macro that calculates it for each data set and then appends it but that's a much more complicated task. I'd only recommend that if your data sets are too big to process as one data set. 

 

data _temp / view=_temp;
set table1-table30 indsname=mySource;
ds = mySource;
keep Good DS;
run;

proc means data=_temp noprint;
by ds NOTSORTED;
var Good;
output out=want mean=Mean_Good;
run;
changxuosu
Quartz | Level 8
thanks, works like a charm...

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 497 views
  • 2 likes
  • 2 in conversation