turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Creating a macro to perform proc means and surveys...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-01-2017 01:02 PM

Hello,

I am using SAS Enterprse MIner 13.1 and am working inside of a SAS Code Node. I have a piece of code that I would like to apply repeatedly to different tables.

Example:

I have multiple tables (there could be a different number of these tables each time my code is ran) they are named Work_1, Work_2, Work_3, etc. They all have the same number of columns with the same names. My final goal is a table with the output of every SurveySelect statement (sample_HALT_1 UNION ALL sample_HALT_2, etc.) .

The process that I would like to perform on each of these tables is:

```
proc means data=Work._1 noprint;
var Diff_MinSS_IndSS;
output out=sample_HALT_1 mean=ha_mean;
run;
data _null_;
set sample_HALT_1;
call symputx('SS_HALT', ha_mean);
run;
%put macro variable SS_HALT: &SS_HALT;
PROC SURVEYSELECT DATA=WORK._1 OUT=sample_HALT_1 METHOD=SRS
Sampsize= &SS_HALT ;
RUN;
```

Any help would be greatly appreciated!

Thanks,

Natasha

Accepted Solutions

Solution

03-03-2017
09:53 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to NatashaLE

03-01-2017 01:15 PM

1. No macros required, use BY GROUP processing.

2.

data work_all;

set work_: indsname=source;

dsn = source;

run;

Then in your next steps add a BY statement using the DSN variable.

For sample size you can provide the dataset instead of a macro variable so the output from proc means can feed directly into SURVEYSELECT. You may want to round the numbers to a whole number.

All Replies

Solution

03-03-2017
09:53 AM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to NatashaLE

03-01-2017 01:15 PM

1. No macros required, use BY GROUP processing.

2.

data work_all;

set work_: indsname=source;

dsn = source;

run;

Then in your next steps add a BY statement using the DSN variable.

For sample size you can provide the dataset instead of a macro variable so the output from proc means can feed directly into SURVEYSELECT. You may want to round the numbers to a whole number.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-03-2017 09:53 AM

Thank you so much for your response! This suggestion allowed me to greatly simplify the process I was building.