BookmarkSubscribeRSS Feed
hhchenfx
Barite | Level 11

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
Barite | Level 11

Sorry for not making it clear.

I'll get back to this issue later.

Thank you,

HHC

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 971 views
  • 0 likes
  • 2 in conversation