BookmarkSubscribeRSS Feed
Piotr900k
Fluorite | Level 6

STACKhELP.png

Hello, 

i want to brings sets together into one data in macro. I have 1064 sets like zm_&next_name and i want to brings them into one data for example ----> data CramerSet; 

8 REPLIES 8
Piotr900k
Fluorite | Level 6

In macro or outside this macro? 

ChrisNZ
Tourmaline | Level 20

it doesn't matter.

This will take all tables starting with  ZM_ .

Piotr900k
Fluorite | Level 6

Ok, I'll check, I have another question. If I have over 1000 sets in one dataset, what should I do to avoid printing those over 1000 sets in the output data?

ballardw
Super User

@Piotr900k wrote:

Ok, I'll check, I have another question. If I have over 1000 sets in one dataset, what should I do to avoid printing those over 1000 sets in the output data?


I'm afraid you have to describe what you mean by "printing over those 1000 sets".

If you are referring to a Set statement in a data step there is no "printing over" going on. It is adding records from each data set.

You can have the same data set on the Set statement multiple times, it just appends the data set each time.

 

ChrisNZ
Tourmaline | Level 20

What you could do, if that's what you want, is:

data INPUT/view=INPUT;

   set ZM_: indsname=INDS;

run;

proc means data=INPUT;

  class INDS:

  ...

run;

No macro needed. Process all the tables in one go and create a single output. 

Piotr900k
Fluorite | Level 6

I have my macro to change variables, and i want to do one data set which include this changed variables, because i need to calculate v-cramer after

ChrisNZ
Tourmaline | Level 20

>I have my macro to change variables, and i want to do one data set which include this changed variables, 

How about something like this:

 

data _null_;
  set ZM_: (obs=1) indsname=INDS;                                   * get all the table names;
  if INDS ne lag(INDS) ;                                            * one process by table  ;
  VAR=substr(INDS,8); * remove WORK.ZM_ to find the variable name;  * extract the analysis variable nane; 
  call execute(' proc means data='||INDS||' nway; id INDS ; out=SUM q1=q1 q2=q2 q3=q3; var ' || VAR 
             ||';proc append data=SUM base=WANT; run;');            * run statistics;
run;

I suspect the 1000 tables are created from a process that could easily create less of a messy output.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 8 replies
  • 598 views
  • 0 likes
  • 3 in conversation