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

Counting Records and formatting the total in SAS


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 4:46 pm
Reply with quote

hi,

I need to count total number of records from an input file in to one o/p file using SAS. The O/P file should display the number of records in the fromat of 99,99,999. Iam using COUNT+1 to count the records. Please let me know how can i get a report with data 99,99,999. when i was using fomat count COMMA. -
FORMAT COUNT COMMA.
FILE SASREPT;
PUT @4 'TOTAL RECORDS: ' COUNT;
it is showing a value of 1.61E6(which is not in the from of 99,99,999) in the SASlog instead of in the O/p file.

thanks,
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Aug 08, 2008 5:10 pm
Reply with quote

FORMAT COUNT COMMA.
will default to the length of 8, so not surprising you get exponential output.

Set the output length to something more reasonable for a large record count.
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 5:16 pm
Reply with quote

in future the number of records may be large ....at this time i cant format it to comma20 rite...its based on the number of records....
i hv also mentioned that the count is not written in to the SAS file........
please provide is there is any better approach..........for these

i dont know much about SAS,,,,but iam trying to get something for this....
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Aug 08, 2008 6:18 pm
Reply with quote

Quote:
at this time i cant format it to comma20


I usually use either COMMA19. or COMMA32.
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 6:21 pm
Reply with quote

THANK YOU VERY MUCH.............
BUT WHERE CAN I USE THIS FORMAT....
WHEN I UESD BEFORE WRITING INTO THE O/P FILE......THE TOTAL REPORT WAS GENERATED IN SAS LOG..AND THE O/P FILE WAS EMPTY.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Aug 08, 2008 6:33 pm
Reply with quote

Take a look at the code that I have used. This only reads a record and increments the counter until EOF.

The FILE statement points to the DDNAME where the output will be written to.
Code:

DATA _NULL_;                   
  FORMAT   COUNT    COMMA32.;   
  INFILE   DATEFILE EOF=EOF1;   
  INPUT    @01  DATEIN    PD4.;
  COUNT + 1;                   
  RETURN;                       
 EOF1:                         
  FILE TESTOUT;                 
  PUT @01 'COUNT WAS   ' COUNT;
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Aug 08, 2008 6:39 pm
Reply with quote

The file that you want to count the records from ......... is it a flat file or a SAS file ?
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 7:06 pm
Reply with quote

Its a VSAM file.....
Iam able to get the o/p file now.......thanks for all ur help....

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Aug 08, 2008 7:13 pm
Reply with quote

Please post your code for the benfit of others, because I know that VSAM files can be a bit of a pain in SAS.

But ................... IDCAMS LISTCAT would give you the record count, and does not have to read through the file.

When the file gets closed the record count is updated in the catalog, and LISTCAT will get the number of records in the file.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Aug 09, 2008 1:01 am
Reply with quote

Quote:
I know that VSAM files can be a bit of a pain in SAS

Not only is VSAM a 4-letter word, but now it is a pain in the SAS. . . icon_cool.gif

Happy Weekend icon_biggrin.gif

d
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Aug 09, 2008 5:35 am
Reply with quote

Quote:
Not only is VSAM a 4-letter word, but now it is a pain in the SAS
groan ... Dick, how could you?

I've never had any problems with VSAM files in SAS; reading them sequentially requires only one difference from a sequential file (the VSAM keyword on the INFILE statement). Reading them randomly isn't as easy in SAS as COBOL but it doesn't require a rocket scientist either.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Aug 09, 2008 9:05 am
Reply with quote

Quote:
groan ... Dick, how could you?
Devil made me. . . Thought i'd see who i could punish. . . icon_wink.gif

Oh, yeah, today is 888, not 666. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Aug 09, 2008 8:55 pm
Reply with quote

Quote:
Oh, yeah, today is 888, not 666. . .
meaning what? You're one-third MORE evil?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Sat Aug 09, 2008 9:18 pm
Reply with quote

Dick, surely tou meant COMMA888.
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Mon Aug 11, 2008 10:38 am
Reply with quote

Quote:
Please post your code for the benfit of others, because I know that VSAM files can be a bit of a pain in SAS.


hi,

Iam using a VSAM file, but while reading iam not using any key.......but iam able to get the o/p with the count equal to i/p records in the input file.....
Let me know if iam doing aything wrong......

DATA MASTER_1
INFILE MASTER EOF=TOTALS;
INPUT @42 DATAT PD4.;
COUNT+1;
here my inout file is MASTER;

Thank You,
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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top