Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to identify a Blank SAS dataset?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: How to identify a Blank SAS dataset?
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

Active Member


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

PostPosted: Fri Jul 20, 2007 5:13 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 20, 2007 6:55 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Allocate dataset withour BLKSIZE Susanta CLIST & REXX 2 Thu Sep 22, 2016 11:51 am
No new posts dataset copy question - REPRO or some... atulxp TSO/ISPF 2 Wed Aug 03, 2016 10:56 pm
No new posts FTOPEN TEMP is failing due to dataset... mbenaud TSO/ISPF 7 Thu Jul 28, 2016 4:28 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us