IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to identify a Blank SAS dataset?


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
aprak00
Warnings : 2

New User


Joined: 09 Aug 2006
Posts: 24

PostPosted: Fri Jul 20, 2007 4:03 pm
Reply with quote

Could anyone please help me to identify a blank SAS dataset?

The scenario is I need to do some processing if a SAS dataset is blank else use the records in the SAS dataset.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Jul 20, 2007 5:13 pm
Reply with quote

Fields or variables can be blank. Do you mean empty, or non-existent?

If empty, input it via SET, with OPTIONS OBS=1, and see if you have a record.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jul 20, 2007 6:55 pm
Reply with quote

Or do you mean a dataset that has been created, allegedly, by SAS but has no internal files. i.e. the physical dataset exists and the previous SAS job(s) have not written to it in any way.

PROC DATASETS should do the trick if this is the case.
Back to top
View user's profile Send private message
rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Mon Jul 23, 2007 3:48 pm
Reply with quote

Code:

DATA DS1;
  INFILE DDNAME1(END=DONE);
  INPUT @001 REC1  $80.;
RUN;

DATA DS2;
  SET DS1;

IF DONE AND _N_ >=1 THEN PUT ' DATASET NOT EMPTY ';
IF DONE AND _N_ <=1 THEN PUT ' DATASET EMPTY ';

RUN;


This might work...

Thanks,
Rajesh
Back to top
View user's profile Send private message
Alan Voss

New User


Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

PostPosted: Mon Jul 23, 2007 9:42 pm
Reply with quote

Code:

DATA WORK.ABC;
  INFILE INSTUFF;
  INPUT ...;
run;

proc sql noprint;
  select nobs into :abcnobs separated by ' '
     from dictionary.tables
     where libname = 'WORK'
         and memname = 'ABC';
  quit;
%put &abcnobs; /* show number of obs */
Back to top
View user's profile Send private message
aprak00
Warnings : 2

New User


Joined: 09 Aug 2006
Posts: 24

PostPosted: Sat Jul 28, 2007 10:40 am
Reply with quote

Hi Alan,

Thanks for the info..

But the "abcnobs" in the code above is returning a junk value not the no: of obs in WORK.ABC.

Could you please let me know the reason?

I used the following code:

Code:
PROC SQL NOPRINT;             
  SELECT NOBS INTO :N_OBS     
     FROM DICTIONARY.TABLES   
     WHERE LIBNAME = "WORK"   
       AND MEMNAME = "TESTO"; 
  QUIT;                       
%PUT &N_OBS;         
Back to top
View user's profile Send private message
Alan Voss

New User


Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

PostPosted: Sun Jul 29, 2007 5:19 am
Reply with quote

I don't understand why you got a "junk value".
Following is my SAS log of WORK.TESTO which I have copied from SASHELP.CLASS (19 observations). Please note, if you don't use the separated by ' ', PROC SQL will not trim off leading blanks.

    NOTE: AUTOEXEC processing completed.

    1 data work.TESTO;
    2 set sashelp.class;
    3 run;

    NOTE: There were 19 observations read from the data set SASHELP.CLASS.
    NOTE: The data set WORK.TESTO has 19 observations and 5 variables.
    NOTE: DATA statement used:
    real time 0.02 seconds
    cpu time 0.02 seconds


    4
    5 PROC SQL NOPRINT;
    6 SELECT NOBS INTO :N_OBS
    7 FROM DICTIONARY.TABLES
    8 WHERE LIBNAME = "WORK"
    9 AND MEMNAME = "TESTO";
    10 QUIT;
    NOTE: PROCEDURE SQL used:
    real time 0.01 seconds
    cpu time 0.01 seconds


    11 %PUT !&N_OBS!;
    ! 19!
    12 PROC SQL NOPRINT;
    13 SELECT NOBS INTO :N_OBS separated by ' '
    14 FROM DICTIONARY.TABLES
    15 WHERE LIBNAME = "WORK"
    16 AND MEMNAME = "TESTO";
    17 QUIT;
    NOTE: PROCEDURE SQL used:
    real time 0.00 seconds
    cpu time 0.00 seconds


    18 %PUT !&N_OBS!;
    !19!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Allocated cylinders of a dataset DB2 12
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts How to identify the transaction categ... IMS DB/DC 3
Search our Forums:

Back to Top