SAS + to find thr number of length in a variable record



Support for C, C++, COBOL, PL/I, Fortran and assembler applications' runtime Environment LE.

SAS + to find thr number of length in a variable record

Postby mainframe1 » Thu Jan 21, 2010 11:54 am

Hi,
how to find the lenght of each record for variable file
say
123445678
123467
1234

i want th record count and byte count for this variable length file in SAS.pls help
mainframe1
 
Posts: 35
Joined: Wed Oct 08, 2008 11:39 am
Has thanked: 0 time
Been thanked: 0 time

Re: SAS + to find thr number of length in a variable record

Postby Robert Sample » Thu Jan 21, 2010 6:29 pm

DATA A;
     INFILE ???????? LENGTH=RL;
     INPUT @;
     RECLEN = RL ;
     LENGTH DATALINE $ 32760;
     INPUT @001 DATALINE $VARYING. RECLEN ;
Getting the record count is trivial using the END option of INFILE.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: SAS + to find thr number of length in a variable record

Postby heronfisher » Mon Mar 15, 2010 3:53 pm

variable labels to files;
do i=1 to n;
labpos=pos(i)+floor((lens(i)-

length(left(varlabel(dsid,i))))/2);

rc=fpos(fid1,labpos);rc=fpos(fid2,labpos);

rc=fput(fid1, varlabel(dsid,i));
rc=fput(fid2, varlabel(dsid,i));
end;
rc=fwrite(fid1,’0’); rc=fwrite(fid2,’0’);
do i=1 to n;
rc=fpos(fid1,pos(i));rc=fpos(fid2,pos(i));
rc=fput(fid1, repeat(’-’,lens(i)-1));
rc=fput(fid2, repeat(’-’,lens(i)-1));
end;
rc=fappend(fid1); rc=fappend(fid2);
heronfisher
 
Posts: 3
Joined: Fri Mar 12, 2010 12:25 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Language Environment