BookmarkSubscribeRSS Feed
17 REPLIES 17
PaigeMiller
Diamond | Level 26

You need to combine the data into a single data set. This is either a MERGE or SET in a DATA step, or a JOIN in PROC SQL. Since we don't have your data, you will have to do this part.

 

Then to do the summing, you want PROC SUMMARY. Example:

 

proc summary nway data=have;
    class name;
    var payment;
    output out=sums sum=sum_payment;
run;
--
Paige Miller
Kurt_Bremser
Super User

If you need to keep the separate datasets, create a view:

data dataview/view=dataview;
set
  data1201
  data1202
  data1203
  ......
;
run;

and then run proc summary over that.

Yona22
Calcite | Level 5
 
Yona22
Calcite | Level 5
 
Patrick
Opal | Level 21

Remove the semicolons between the table names. The syntax needs to be a SET statement with a list of tables name and then a single semicolon which terminates the statement.

If code has errors then also please always the SAS log which shows the actual error message.

Yona22
Calcite | Level 5
 
Kurt_Bremser
Super User

Use call execute() in a data step to create the actual data step:

data _null_;
period = '01mar2002'd;
call execute('data want; set');
do until (period > '01dec2019'd);
  call execute(' data' !! substr(put(year(period),z4.),3,2) !! put(month(period),z2.));
  period = intnx('month',period,1,'b');
end;
call execute(';run;');
run;
PeterClemmensen
Tourmaline | Level 20

If all of the desired input data sets start with "tab", you can do

 

data comp;
    set tab:;
run;
Patrick
Opal | Level 21

Please don't ask the same question twice. This only messes up discussions. @Kurt_Bremser has already given you a working answer here.

Kurt_Bremser
Super User

I merged this back into the original question.

 

You can use the method I posted with any prefix, and any dataset with an additional suffix will be excluded.

ballardw
Super User

@Yona22 wrote:
Hi, I have lots of dataset and named with year and months (TAB0203, TAB0204,..... until TAB1912). I want to extract all of them. This is my code

DATA COMB;
SET TAB0203
TAB0204
....
TAB1912;

RUN;

But it only read the 3 dataset and didn't read the rest of the data from TAB0205 until TAB1911. May I know how should I write for the code in order to read all of them?

AS was suggested before: COPY the LOG and paste the copied text into a code box opened on the Forum with the {I} or "running man" icon.

Yona22
Calcite | Level 5