DATA Step, Macro, Functions and more

get the max value of one variable among all datasets saved under work.

Reply
Contributor
Posts: 50

get the max value of one variable among all datasets saved under work.

  I want to identify the max value of one variable among all identical datasets (have same variables in each dataset) created and saved under work and exact the row. But got a note:

NOTE: A stored DATA STEP view cannot run under a different operating system.

data allscan/view = allscan;

     set optimal_:indsname=dsname;

                 run;

proc sql;

create table min as

select * from allscan

having EN=min(EN);

quit;

 

 

NOTE: DATA STEP view saved on file WORK.ALLSCAN.

NOTE: A stored DATA STEP view cannot run under a different operating system.

NOTE: DATA statement used (Total process time):

real time 0.03 seconds

cpu time 0.01 seconds

 

ERROR: The following columns were not found in the contributing tables: EN.

NOTE: View WORK.ALLSCAN.VIEW used (Total process time):

real time 0.01 seconds

cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE SQL used (Total process time):

real time 0.03 seconds

cpu time 0.03 seconds

Respected Advisor
Posts: 4,922

Re: get the max value of one variable among all datasets saved under work.

A Note is just a note, it doesn't signal an error. The error seems to be that at least one of your WORK.OPTIMAL_* datasets doesn't include a variable called EN. - PG

PG
Contributor
Posts: 50

Re: get the max value of one variable among all datasets saved under work.

I used the %sysfunc to check the nobs and delete it if it is empty. But it seems that the empty datasets were still there.

%do i = 2 %to &maxN;

    %joint(&i,&i); *** create table optimal_&i;

         *** check if the data is empty;

        %LET dsid=%SYSFUNC(OPEN(work.optimal_&i));

     %LET nobs=%SYSFUNC(ATTRN(&dsid.,NOBS));

     %LET rc=%SYSFUNC(CLOSE(&dsid.));

     %IF &Nobs. EQ 0 %THEN %DO;

            proc datasets;

                 delete optimal_&i;

               run;

     %END;

%end;

data allscan/view = allscan;

     set optimal_:indsname=dsname;

        run;

proc sql;

create table opt as

select * from allscan

having EN=min(EN);

quit;

Ask a Question
Discussion stats
  • 2 replies
  • 213 views
  • 0 likes
  • 2 in conversation