February 08, 2007, 01:43 AM
manashHow to get the output in the mentioned format?
hi
I have a input file with 5 fields
roll no. name phone email fax no.
------- ------ ------- --------- --------
111 aaa 1234567 a@yyy.com 1234567
222 bbb 2345678
333 ccc c@yyy.com
Now in the output file I need to print the fields in following format
roll no. NAME name
PHONE phone
EMAIL email
FAX NO. fax no.
NOTE:- That the words written with caps on are labels not fields and the one with caps off
are fields.
the output should be as follows:-
111 NAME aaa
111 PHONE 1234567
111 EMAIL a@yyy.com
111 FAX NO. 1234567
222 NAME bbb
222 PHONE 2345678
333 NAME ccc
333 EMAIL c@yyy.com
Note:- The fields which are null for a particular roll no. should not be printed
As roll no. 222 does'nt have email and fax field so they are not printed in the output.
February 08, 2007, 04:29 AM
FrankDutchdid you download the manual?
try the command "OVER"
so
TABLE FILE CAR
PRINT
COUNTRY AS 'c:' OVER
CAR AS 'x:' OVER
MODEL AS 'm:' OVER
COMPUTE SPACE/A1 = ''; AS ''
ON TABLE NOTOTAL
ON TABLE SET HTMLCSS ON
END
February 08, 2007, 04:50 AM
FrankDutchyour second question is a select:
WHERE EMAIL NE '';
And if you want to repeat the ROLLNO
PRINT
ROLLNO AS '' NAME OVER
ROLLNO AS '' PHONE OVER
ROLLNO AS '' EMAIL OVER
ROLLNO AS '' FAXNO
But if you just want to suppress only lines when the value is empty you have to do this in a complete other way.
First put all the data into a new hold file per field.
But than you need the fields to have the same picture (p.e. A25)
-SET ASNAMES= ON
TABLE FILE XXX
PRINT ROLLNO
COMPUTE FNAME/A10="PHONE"
PHONE AS 'FVALUE'
ON TABLE HOLD AS HOLDPHON
WHERE PHONE NE '';
END
TABLE FILE XXX
PRINT ROLLNO
COMPUTE FNAME/A10="EMAIL"
EMAIL AS 'FVALUE'
ON TABLE HOLD AS HOLDMAIL
WHERE EMAIL NE '';
END
etc
Then combine the HOLD files
TABLE FILE HOLDMAIL
PRINT ROLLNO FNAME FVALUE
ON TABLE HOLD
MORE
FILE HOLDPHON
MORE
FILE HOLDFAX
MORE
...
END
TABLE FILE HOLD
PRINT *
END
Let me know if it works
and download the manual, it will help you a lot.
Frank
February 08, 2007, 11:22 PM
manashYa Frank it worked .Thanx a lot.
And ya I downloaded the manual and i m going through it.