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

Need to Build SAS Title based on Input Fields


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
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
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: 1742
Location: Tirupur, India

PostPosted: Thu Dec 08, 2011 1:01 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Dec 08, 2011 1:22 pm
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: 8797
Location: Welsh Wales

PostPosted: Thu Dec 08, 2011 1:33 pm
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Dec 08, 2011 2:34 pm
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: 2481
Location: Netherlands, Amstelveen

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

Some samples are to be found here :

www2.sas.com/proceedings/sugi29/243-29.pdf
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
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: 2455
Location: Hampshire, UK

PostPosted: Thu Dec 08, 2011 3:31 pm
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
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Dec 08, 2011 4:59 pm
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
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
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: 1742
Location: Tirupur, India

PostPosted: Thu Dec 08, 2011 6:07 pm
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: 1742
Location: Tirupur, India

PostPosted: Thu Dec 08, 2011 6:12 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts force tablespace using LISTDEF input DB2 1
No new posts Two input files & writing counter... DFSORT/ICETOOL 12
No new posts Use input file with OMIT rcd keys? DFSORT/ICETOOL 15
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
Search our Forums:

Back to Top