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

JOB name & number using SAS


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

New User


Joined: 03 Jan 2007
Posts: 15
Location: US

PostPosted: Tue Nov 25, 2008 2:22 am
Reply with quote

Hi,
Is there a way to get the jobname and number using SAS program? I need to generate a report that should have the jobname and number of the job that generated that report.
Am an amateur in SAS programming. Could someone please help?
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Tue Nov 25, 2008 12:45 pm
Reply with quote

Why is it so important to have the jobname and job number ?
Dare I ask if this is a homework assignment ?

You can find out which 'automatic' variables are available by

%put _AUTOMATIC_;

If unavailable, then it is time to start chasing down system control blocks. Good Luck
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Nov 25, 2008 7:30 pm
Reply with quote

Found this code. Maybe it'll work for you:
Code:

//SASSTEP  EXEC SAS                                         
//SYSIN    DD   *                                           
DATA _NULL_;                                                 
  LENGTH JOBNAME $8 PROCSTEP $8 STEPNAME $8 PROGNAME $8     
    JOBNUMBR $8 JOBID $5 USERID $8;                         
TIOTPTR = PEEK(PEEK(540)+12);                               
JOBNAME = PEEKC(TIOTPTR,8);                                 
PROCSTEP = PEEKC(TIOTPTR+8,8);                               
STEPNAME = PEEKC(TIOTPTR+16,8);                             
                                                             
JSCBPTR = PEEK(PEEK(540)+180);                               
PROGNAME = PEEKC(JSCBPTR+360,8);                             
                                                             
SSIBPTR = PEEK(JSCBPTR+316);                                 
JOBNUMBR = PEEKC(SSIBPTR+12,8);                             
JOBID = PEEKC(SSIBPTR+15,5);                                 
                                                             
JCTPTR = PEEK(JSCBPTR+260);                                 
JOBCLASS = PEEKC(JCTPTR+47,1);                     
MSGCLASS = PEEKC(JCTPTR+22,1);                     
                                                   
USERID = PEEKC(PEEK(PEEK(548)+108)+192,8);         
                                                   
CALL SYMPUT('JOBNAME', JOBNAME);                   
CALL SYMPUT('PROCSTEP', PROCSTEP);                 
CALL SYMPUT('STEPNAME', STEPNAME);                 
CALL SYMPUT('PROGNAME', PROGNAME);                 
CALL SYMPUT('JOBID', JOBID);                       
CALL SYMPUT('JOBCLASS', JOBCLASS);                 
CALL SYMPUT('MSGCLASS', MSGCLASS);                 
CALL SYMPUT('USERID', USERID);                     
                                                   
PUT 'JOBNAME=' JOBNAME;                             
PUT 'JOBID=' JOBID;                                 
PUT 'STEPNAME=' STEPNAME;                           
PUT 'PROCSTEP=' PROCSTEP;                           
PUT 'PROGNAME=' PROGNAME;                           
PUT 'JOBCLASS=' JOBCLASS;                           
PUT 'MSGCLASS=' MSGCLASS;                           
PUT 'USERID=' USERID;                               
RUN;
/*   
Back to top
View user's profile Send private message
pranavaraj

New User


Joined: 03 Jan 2007
Posts: 15
Location: US

PostPosted: Wed Nov 26, 2008 12:18 am
Reply with quote

Thanks to you both.

Hi Expat,
This isn't homework assignment icon_biggrin.gif. Actually we are sending a daily report to the end user and that report was generated using SAS. Sometimes they will comeback and ask questions about the report. So to track down the date the report was generated we are including the jobname and number in the report.
And in %put _AUTOMATIC_; i was able to get the job name and not the job number icon_sad.gif


Hi superk,
Your code works perfectly. And am going to incorporate the same in the code. Thx so much 2014.gif


Another question reg SAS please... Is there a way to call any assembler routine in SAS program?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Nov 26, 2008 12:34 am
Reply with quote

Look on the SAS site for CALL MODULE -- you can invoke external programs from within SAS via this mechanism. There are some restrictions and warnings depending on which release of SAS you're using.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Wed Nov 26, 2008 1:16 pm
Reply with quote

Quote:
So to track down the date the report was generated we are including the jobname and number in the report.

Would it not be easier to use the date and time displayed at the top of each page rather than include code to give you information that does not reflect the date and time of report generation.
Back to top
View user's profile Send private message
pranavaraj

New User


Joined: 03 Jan 2007
Posts: 15
Location: US

PostPosted: Wed Dec 03, 2008 2:34 am
Reply with quote

expat wrote:
Quote:
So to track down the date the report was generated we are including the jobname and number in the report.

Would it not be easier to use the date and time displayed at the top of each page rather than include code to give you information that does not reflect the date and time of report generation.



Yes. But not everyone knows that this report is generated out of that particular JCL. So to have a better understanding, we are including the Job name and number.
Back to top
View user's profile Send private message
pranavaraj

New User


Joined: 03 Jan 2007
Posts: 15
Location: US

PostPosted: Wed Dec 03, 2008 2:44 am
Reply with quote

Hi,
Actually the report is generated out of TABULATE proc and am not able to incorporate the above mentioned piece of code (by superk) in that.

Here's my code,

OPTIONS MPRINT MLOGIC SYMBOLGEN LINESIZE=80 PAGESIZE=75;

OPTIONS ERRORS=1 NONUMBER PAGESIZE=74 MISSING = '0';
*;

PROC FORMAT;
VALUE $ACT
'ORD' = 'ORDER'
'PAY' = 'PAYMENT'
'CAN' = 'CANCEL';

DATA TRAN;
INFILE INRPT;
FORMAT ENTRDATE MMDDYY8.;
INPUT @221 ENTRDATE PDJULI4.
@233 ACTIVITY $3.
@1081 EFFKEY $6.;
LENGTH JOBNAME $8 JOBNUMBR $8 JOBID $5;

PROC PRINTTO UNIT=17;

PROC SORT DATA=TRAN;
BY EFFKEY;

PROC TABULATE DATA=TRAN FORMAT=COMMA9.0;
CLASS EFFKEY;
TABLE (EFFKEY='ORDERS FROM THIS FILE') ALL , N
/ CONDENSE MISSTEXT=' ';
KEYLABEL N = 'COUNTS'
ALL = 'TOTAL';
TITLE 'FILES RECEIVED ON';
RUN;

TIOTPTR = PEEK(PEEK(540)+12);
JOBNAME = PEEKC(TIOTPTR,8);


CALL SYMPUT('JOBNAME', JOBNAME);

PUT 'JOBNAME=' JOBNAME;

PROC PRINT DATA=_NULL_;
TITLE 'FITNESS DATA';
RUN;


and am receiving error msg as,

"Statement is not valid or it is used out of proper order"

after the TIOTPTR = PEEK(PEEK(540)+12) statement.

Am sure that am doing something very wrong or trying something which is not possible. But am not able to decode it. I tried to google it and solve it but in vain. Could someone please help?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 03, 2008 4:57 am
Reply with quote

Try this:
Code:
DATA _NULL_ ;
TIOTPTR = PEEK(PEEK(540)+12);
JOBNAME = PEEKC(TIOTPTR,8);
These statements you have are part of the DATA step and cannot be placed willy-nilly in the program -- or you'll get a syntax error about the statement being out of the proper order (as you found).
Back to top
View user's profile Send private message
pranavaraj

New User


Joined: 03 Jan 2007
Posts: 15
Location: US

PostPosted: Thu Dec 04, 2008 3:18 am
Reply with quote

Thanks Robert.
That worked. But i need to get the jobname and number in the report. So i used a Print proc to get that.

So after this
PROC TABULATE DATA=TRAN FORMAT=COMMA9.0;
CLASS EFFKEY;
TABLE (EFFKEY='ORDERS FROM THIS FILE') ALL , N
/ CONDENSE MISSTEXT=' ';
KEYLABEL N = 'COUNTS'
ALL = 'TOTAL';
TITLE 'FILES RECEIVED ON';
RUN;


i used print proc as follows,

PROC PRINT;
TITLE 'JOBNAME';

DATA _NULL_ ;
LENGTH JOBNAME $8 JOBNUMBR $8 JOBID $5;
TIOTPTR = PEEK(PEEK(540)+12);
JOBNAME = PEEKC(TIOTPTR,8);

PUT 'JOBNAME=' JOBNAME;

RUN;


But in the report, just the title is getting printed and not the jobname. the job name is displayed in SASLOG.

someone please help.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 04, 2008 5:22 am
Reply with quote

Use SYMPUT to output the values into macro variables; use &MACROVARIABLENAME to use in the title. Check the SAS web site if you haven't used SYMPUT and SYMGET before -- they're straightforward but not easily understood at first.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Thu Dec 04, 2008 3:12 pm
Reply with quote

Following on from Robert ................

The only way that I have done something like this in the past is by using the macro variables in the title lines. Try it and see if it helps you.
Code:

 DATA _NULL_;                     
  ABC = DATE();                   
  BCD = PUT(ABC,DATE9.);         
  CALL SYMPUT ('DEF',BCD);       
                                 
 DATA OUT01;                     
   AAA = 1; OUTPUT;               
   AAA = 2; OUTPUT;               
   AAA = 3; OUTPUT;               
   AAA = 4; OUTPUT;               
   AAA = 5; OUTPUT;               
                                 
 PROC PRINT DATA=OUT01 NOOBS;     
  TITLE1 'CREATE BY ME ON' &DEF ;
Back to top
View user's profile Send private message
pranavaraj

New User


Joined: 03 Jan 2007
Posts: 15
Location: US

PostPosted: Fri Dec 05, 2008 2:22 am
Reply with quote

Thanks soooo much...
I tried what expat has suggested and it worked fine icon_super.gif
Back to top
View user's profile Send private message
pranavaraj

New User


Joined: 03 Jan 2007
Posts: 15
Location: US

PostPosted: Sat Dec 06, 2008 8:33 am
Reply with quote

Hi Expat,
Instead of using PRINT proc, i displayed the jobname and number using FOOTNOTE in TABULATE proc itself.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Sat Dec 06, 2008 1:45 pm
Reply with quote

That's another option. I was pointing at using the TITLE line in TABULATE. The PROC PRINT was only an example
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 Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top