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
 

 

Need to Build SAS Title based on Input Fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 12:29 pm    Post subject: Need to Build SAS Title based on Input Fields
Reply with quote

Hi,

I am trying to build SAS Title based on Input fields from a Control Card.
There will be 5 fields in control card. But my title is bsed on 2 fields from those 5. Fields can be default or some value in it. Default wil be 9's

fields
ID - 3 byte
Loc - 3 byte
gender - 2 byte
emp-type - 2 byte
Salary - 6 byte

I can have combinations of fields and depending on which i am trying to generate a report. ANd this report needs to have a title based on ID and EMp-type.

If ID = 999 and EMP-TYPE = 99 IT MEANS REPORT IS NOT BASED ON THESE FIELDS

IF id = ABC AND EMP-TYPE = 99 IT MEANS REPORT IS BASED ON ID

IF ID = ABC AND EMP-TYPE = 01 THEN IT MEANS REPORT IS BASED ON BOTH

IF ID = 999 AND EMP-TYPE = 01 THEN IT MEANS REPORT IS BASED ON EMP-TYPE ONYL.

NOW MY REQUIREMENT IS TO SHOW THE CRITERIA ON WHICH MY REPORT GOT GENERATED.

FOR EXAMPLE
ID - 999
TYPE - 01

TITLE NEEDS TO BE - TITLE "CRITERIA: TYPE - 01"

EX2:
ID - ABC
TYPE - 01

TITLE "CRITERIA: ID - ABC TYPE - 01"

EX3
ID - ABC
TYPE - 99
TITLE "CRITERIA: ID - ABC"

EX4
ID - 999
TYPE - 99

NO TITLE

======
i am trying to do this in a SAS program, as a macro.

I would need code for the same.

Input - Control Card Example -
Control card can have max of 5 rows. with each row having 16 bytes each and no criteria on a fields will be represented by 9's.
default value for a field will be 9's.

ex:

Fields in a row - ID/loc/gender/emp-type/salary wil be without any space inbetween.
ABCOHIFEPE500000

EX2:
999FLOMA99126700

Ex3:
BCDPENFE99670000

EX4:
999BOSMATE230000

Reading this input say if they are in a control card as 4 rows.
Then my title needs to be like

TITLE "CRITERIA: ID - ABC TYPE - PE"
TITLE "CRITERIA: ID - BCD"
TITLE "CRITERIA: TYPE - TE"

Thanks
-Kranthi
Back to top
View user's profile Send private message

vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Thu Dec 08, 2011 1:01 pm    Post subject:
Reply with quote

Hi,
If there are subsequent title statements on after the other, then I guess you are aware that the last title statement would override the previous title statements and only the last title statement would be in effect.

So If you have 4 control cards and somehow generate 4 title statements, then only the 4th title statement would be in effect.

on the other hand,
The 4 titles will be simultaneously in effect only if you have statements like,

TITLE1 "something"
TITLE2 "something else"
TITLE3 "some other thing"
TITLE4 "some some other thing"

Are you sure that you require title statements subsequently?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Dec 08, 2011 1:22 pm    Post subject: Reply to: Need to Build SAS Title based on Input Fields
Reply with quote

Does SAS allow datanames in title statements? If so, get on with the code.

If not, find the "highest level" element in a SAS report description which can have a dataname, and use that.
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: Thu Dec 08, 2011 1:33 pm    Post subject:
Reply with quote

Easily enough done using a macro. Have done it myself many a time.
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 2:29 pm    Post subject:
Reply with quote

@Vasanth,

It is not 4 control cards...
It is 4 records in a control card.

Yes I would need 4 Titles if I have 4 records in control card.

I wanted to do it using MACRO. But not sure of what/how it can be done.

@ Others,
Please post the MACRO coding.

Thanks to every one for the replies.
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: Thu Dec 08, 2011 2:34 pm    Post subject:
Reply with quote

You need to analyse your input data to determine the contents of the title pages, and then build a macro variable to contain that information.

Then use
Code:

Title1 = &variable.


Kranthi wrote:
M@ Others,
Please post the MACRO coding.

My daily rate for such activites is 750 euro. Code delivered upon receipt of payment icon_lol.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu Dec 08, 2011 2:43 pm    Post subject:
Reply with quote

Some samples are to be found here :

http://www2.sas.com/proceedings/sugi29/243-29.pdf
http://www2.sas.com/proceedings/sugi26/p153-26.pdf
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 3:12 pm    Post subject:
Reply with quote

Hi,

Every time I read a record from Control card, I want to call a macro that will build title based on input. How Can i do it?

In that case do i need to have the DATA part of control card within the MACRO or outside macro.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Thu Dec 08, 2011 3:31 pm    Post subject:
Reply with quote

What happens when you try various options?
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 3:42 pm    Post subject:
Reply with quote

for each record in the control card I need a title. And title needs to have variables from control card.
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 4:23 pm    Post subject:
Reply with quote

Can some one tell what is wrong with below code:
It says MACRO is not invoked. Warning - Apparent invocation of macro CRITERIA not resolved.

and an error

ERROR: Expected %TO not found in %DO statement. A dummy macro will be compiled.
=====

DATA FILEA;
INFILE CARDIN;
INPUT @01 ID $03.
@04 LOC $03.
@07 GENDER $02.
@09 EMPTYPE $02.
@11 SALARY $06.
@17 FILL1 $64.;
TEMPVAR = 'ANY VALUE'; /* THIS NEEDED TO GET SYMPUT TO WORK */
CALL SYMPUT('ID1',ID);
CALL SYMPUT('EMPTYP',EMPTYPE);
%CRITERIA(IDEN=&ID1,EMPT=&EMPTYP);
%MACRO CRITERIA;

%IF &IDEN = 999
%THEN %DO
SELECT = 1;
TITLE1 "CRITERIA SYMBOL &SYM AND STATE &RST";
%IF &EMPT = 99

%THEN %DO SELECT = 2;
TITLE1 "ALL SYMBOLS AND ALL STATES";
%END;
%ELSE
%DO SELECT = 3;
TITLE1 "CRITERIA SYMBOL &SYM";
%END;
%ELSE
%DO SELECT = 4;
TITLE1 "CRITERIA RISK STATE &RST";
%END;

%MEND CRITERIA;
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: Thu Dec 08, 2011 4:59 pm    Post subject:
Reply with quote

Have you tried to define the macro before you try to invoke it
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 5:07 pm    Post subject:
Reply with quote

Yes, i have it a library and I used some option to tell SAS that macro is in certain library.

Now invocation is not problem.

%LOSO720D(IDEN=&id1,EMPT=&EMPTYP);
an error at above line - says
Statement is not valid or it is used out of proper order.

And the DO seems to have some problem in the MACRO. it gives an error

Expected %TO not found in %DO statement.
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Thu Dec 08, 2011 5:27 pm    Post subject:
Reply with quote

Just happened to resolve 1 issue with
%CRITERIA(IDEN=&ID1,EMPT=&EMPTYP);

As ID and EMPTYPE are global, i dont need to pass them while invoking. just use them with & within MACRO.

Looking into other issue.

Thanks
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Thu Dec 08, 2011 6:07 pm    Post subject:
Reply with quote

One more obvious error is, the macro criteria has 4 %DOs and 3 %ENDs.
1 more is needed.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Thu Dec 08, 2011 6:12 pm    Post subject:
Reply with quote

Also All the %DO statements in your program
has to have an accompanying %TO statement or has to end with a semicolon.
like %DO;
Back to top
View user's profile Send private message
Kranthi M

New User


Joined: 07 Oct 2011
Posts: 20
Location: India

PostPosted: Fri Dec 09, 2011 4:12 pm    Post subject:
Reply with quote

Thanks Vasanth. I resolved the DO loop thing. But this way I was only printing one title as you said. It was overriding all others.

So for printing all the titles i might need to use ARRAY and then use
Instead of TITLE, I am just displaying all the records in the control card with a title saying CRITERIA using PROC PRINT. And another PROC PRINT to print the actual REPORT. This way I can display the CRITERIA in a easy way.

I know this is not what I intended for initially but can not afford to put more efforts by building macro and use ARRAYs as well to build 10 titles dynamically.

Thanks every one!
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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm


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