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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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