SAS report



Post anything related to mainframes (IBM & UNISYS) if not fit in any of the above categories

SAS report

Postby Kitz » Wed May 11, 2011 8:14 pm

Hi,

Please could anyone help me to create/reformat a report in SAS:

My input file has FIELD1(Max of 16 characters) FIELD2(Max 10 ) FIELD3(Max 1) with a SPACE in between each field.

My input file is something like below:
AXXXXX12345 1105111400 W
AXX34 1105101800 W
AXXXXXX123456789 1105111400 W
AXX3467 1105101500 W

Output should be of the format as below:
AXXXXX12345 1105111400 W
AXX34 1105101800 W
AXXXXXX12345678 1105111400 W
AXX3467 1105101500 W

I tried using below SAS program using SPACE delimiter; but it doesn't work properly. The reports breaks.
//SYSIN DD *
OPTIONS NOCENTER;
DATA INFILE;
INFILE UT01 DELIMITER=',';
INPUT APPL £16. IA £10. STATUS £1. ;
PROC PRINT DATA=INFILE;

DATA OFILE;
SET INFILE;
FILE UT11;
PUT @1 APPL
@20 IA
@30 STATUS
;

Please help.

Thansk & Regards,
Kitz
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: SAS report

 

Re: SAS report

Postby Robert Sample » Wed May 11, 2011 8:26 pm

Since you did NOT use the Code tag, your input and output look exactly the same.

This code should do it:
DATA _NULL_;
     LENGTH APPL $ 16 IA $ 10 STATUS $ 1;
     INFILE UT01;
     INPUT APPL IA STATUS;
     FILE OUTFILE;
     PUT @01 APPL $16. @20 IA $10. @30 STATUS $1.;
Robert Sample
Global moderator
 
Posts: 3507
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 248 times

Re: SAS report

Postby Robert Sample » Wed May 11, 2011 8:28 pm

I just noticed -- that should be FILE UT11; not FILE OUTFILE;
Robert Sample
Global moderator
 
Posts: 3507
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 248 times

Re: SAS report

Postby Kitz » Wed May 11, 2011 9:35 pm

Vow...it worked. Thanks very much Robert.

Thanks & Regards,
Kitz
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: SAS report

Postby Robert Sample » Wed May 11, 2011 10:40 pm

it worked
You're surprised? I've been using SAS at various work locations for well over 30 years now!

The LENGTH statement defines the variable lengths. An unformatted INPUT statement such as I used will read character data either until the first space or the length of the variable (SAS defaults to 8 bytes for character variables, which is why the LENGTH statement was needed). Numbers will be read until the first space (although SAS may do some truncation if the value exceeds normal limits for a numeric variable).
Robert Sample
Global moderator
 
Posts: 3507
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 248 times

Re: SAS report

Postby Kitz » Thu May 12, 2011 8:03 pm

Thank you Robert. I tried with LENGTH but somehow it didn't work. I got it now. Well explained, thanks.
Kitz
 
Posts: 47
Joined: Thu Mar 17, 2011 3:46 am
Has thanked: 0 time
Been thanked: 1 time

Re: SAS report

Postby Robert Sample » Thu May 12, 2011 8:07 pm

Glad to hear it helped. :)
Robert Sample
Global moderator
 
Posts: 3507
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 248 times


Return to All other Mainframe Topics

 


  • Related topics
    Replies
    Views
    Last post