BookmarkSubscribeRSS Feed
hhchenfx
Rhodochrosite | Level 12

Hi Everyone,

My data is like that:

period     day     var1     var2...

Each period has many days and I make day index variable (1 to n for the whole dataset)

I make a macro to analyze data for each Day and combine daily result into a Period_file.

Since there is no rule for when is the first day of the period, I don't know how to tell SAS that, create a new Peirod_file when start new group of iteration.

It should be something like that

Data Summary_.

     if (START of new start/end group) %then %do;
          set daily;
          %end;
     %else %do;
          set Summary_&period      daily;
          %end;

run;

Thank you so much for your help.

HHC

The whole sample code is like that:

%macro test (start,end,period);
    %do i=&start %to &end;
           data Temp_&i;      set mydata;
           if day= &i;  run;
*ANALYSIS SECTION FOR EACH Period FILE; there will be 01 summary file per period;
Proc means noprint;
var  var1;
output out=daily
N=N;run;

Data Summary_.

if (START of new start/end group) %then %do;
set daily;
%end;
%else %do;
set Summary_&period daily;
%end;

run;

   %end;
%mend test;
%test (1,50,1);
%test (51,65,2);

2 REPLIES 2
LinusH
Tourmaline | Level 20

Hard to follow your requirement.

Please attach some sample input and desired output data.

Data never sleeps
hhchenfx
Rhodochrosite | Level 12

Sorry for not making it clear.

I'll get back to this issue later.

Thank you,

HHC

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1349 views
  • 0 likes
  • 2 in conversation