Fehler-Behandlung nach proc sql

Hallo zusammen,
ich habe das aktuelle Problem, dass ein PROC SQL Fehler im LOG meldet, ich aber keine Fehler-Behandlung programmieren kann, weil z.B. die SYSERR-Variable 0 (für OK) enthält.
Welche Möglichkeiten gibt es noch ein Fehler-Situation zu erkennen?

proc sql noprint;
select count(*), name
into :AnzVars, :vars separated by ' '
from dictionary.columns
where upcase(libname)=upcase("sashelp") and upcase(memname)=upcase("class")
;
quit;
%put INFO: SYSERR=&SYSERR.;

Im Log kommt der Fehler
ERROR: Expecting page 1, got page -1 instead.
ERROR: Page validation error while reading DM3SE.F_KOPO_E.DATA.

Und der put liefert:
INFO: SYSERR=0

Ich möchte, dass das Programm nach diesem (und ähnlichen) Fehlern abbricht, aber dazu müßte das Programm die Fehler-Situation erkennen ....

Gruß
Hans Kneilmann, Schäfer Shop GmbH (SSI)

Hallo Herr Kneilmann,es ist

Hallo Herr Kneilmann,

es ist nur so eine Idee. Vielleicht können Sie die Informationen über die Datei auch wie folgt abfragen:

%let dsid=%sysfunc(open(sashelp.class,is));
%let nobs=%sysfunc(attrn(&dsid,nobs));

(oder mit einem Makro von Roland Rashleigh-Berry:
%macro attrn(ds,attrib);

%local dsid rc;

%let dsid=%sysfunc(open(&ds,is));
%if &dsid EQ 0 %then %do;
%put ERROR: (attrn) Dataset &ds not opened due to the following reason:;
%put %sysfunc(sysmsg());
%end;
%else %do;
%sysfunc(attrn(&dsid,&attrib))
%let rc=%sysfunc(close(&dsid));
%end;

%mend;
)

Falls die Datei defekt ist sollten Sie so eine auswertbare Fehlerinformation bekommen (bei mir kann ich ihr Problem nicht nachstellen).
Die Namen der Datei könnten dann ähnlich abgefragt werden.

Grüße MK

Gute Idee

Hallo,
das war die richtige Idee!
Vor allem hat sie mich darauf gebracht nachzudenken, was ich alles schon an Macro habe!!!
Die Lösung:

%let infile=sashelp.class;
%obsnvars(&infile., AnzVars, nobs );
%let vars=%VarList(&infile.);
%put INFO: AnzVars=&AnzVars.;
%put INFO: vars=&vars.;

statt dem alten zu-Fuß-Code (siehe oben). Der alte zu-Fuß-Code hat noch den weiteren Nachteil, dass SAS (selbst ohne die Fehler-Situation) 1000-de Notes und Info in den LOG schreibt:

/*
NOTE: The query requires remerging summary statistics back with the original data.
INFO: Data file DMWORKV5.AM751010_FL01_001_CLEAN.DATA is in a format that is native to another host, or the file encoding does not match the session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce performance.
INFO: Data file DMWORKV5.AM751010_RB01_001_MEKO.DATA is in a format that is native to another host, or the file encoding does not match the session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce performance.
*/

Die Macros obsnvars und VarList sind im Prinzip alle im Redscope-Forum bekannt, siehe Macro-Sammlung (http://www.redscope.org/makros)

Danke nochmal für den Denkanstoß!

Gruß
Hans Kneilmann, Schäfer Shop GmbH (SSI)

Moin, moin, Da haben Sie

Moin, moin,

Da haben Sie offensichtlich eine "Macke" von SAS entdeckt.
Hat AnzVars in dem Fall überhauüt Variablen? Wenn nicht könnte man den Leerstring abfangen

Grüße // Martin Schaefer

Abfrage auf gefüllt

Hallo Herr Schaefer,
leider sind die beide Variablen sauber gefüllt ....
Das Abfragen auf gefüllt wäre auch nur eine Krücke, denn die nächste Falle wartet schon:

data _null_;
set sashelp.vtable(keep=LIBNAME MEMNAME COMPRESS) end=end;
where kupcase(LIBNAME)=kupcase("&_lib.") and kupcase(memname)=kupcase("&_dset.");
if end then do;
put COMPRESS=;
if kupcase(COMPRESS) NE kupcase("NO") then COMPRESS=kupcase("YES");
call symput("COMPRESS", COMPRESS);
end;
run;

reagiert genauso doof auf das kaputte Data Set, das in diesem Moment vollkommen unwichtig ist!
SAS soll einfach die Info aus der sashelp.vtable bzw. dictionary.columns liefern, ohne zusätzlich eine Rundum-Kontrolle-ob-alles-OK durchzuführen. Dieses Kontrolletti-Spiel ist m.E: die "Macke" ...

Gruß
Hans Kneilmann, Schäfer Shop GmbH (SSI)