Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SAS: capture the condition when number of records > 100

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
ganeshcet

New User


Joined: 25 Jan 2007
Posts: 11
Location: New York

PostPosted: Tue May 08, 2007 5:37 am    Post subject: SAS: capture the condition when number of records > 100
Reply with quote

Hi
i have question on sas.in sas program currently i am using array

array branch(100) _temporary_ ;

then later

branch(i) = a+b;

where 100 is the number if records in the input file .i add a+b for all branches. (just looping it) .Now i want to capture the condition when number of records is more than 100. how can i know the count first and set it ? please help .
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue May 08, 2007 1:02 pm    Post subject:
Reply with quote

You want to know the number of branches before you build your array ?
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Tue May 08, 2007 5:56 pm    Post subject:
Reply with quote

For a small-ish file:

1. DATA step #1 reads the file, counting records, and at end sets the value of a macro variable to this number

2. DATA step #2 can now do better than what you wanted. It can size the array using the macro variable, thereby effectively dynamically allocating the array to just the size you want

3. DATA step #2 then re-reads the file, knowing that the array is sized correctly
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue May 08, 2007 6:20 pm    Post subject:
Reply with quote

If the input data is already in SAS format you could just use the NOBS keyword to get the number of observations in the dataset.

SET &FILEIN (OBS=1) NOBS=NNN;
Back to top
View user's profile Send private message
ganeshcet

New User


Joined: 25 Jan 2007
Posts: 11
Location: New York

PostPosted: Wed May 09, 2007 9:41 pm    Post subject:
Reply with quote

Hi
thanks for the help.
here is the code for the macro variable.

DATA _NULL_;
INFILE inputfileddname END=EOF;
INPUT;
IF EOF THEN
CALL SYMPUT('X',_N_);
RUN;

DATA _NULL_;
array arrayvariable(&x) _temporary_;
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Thu May 10, 2007 6:14 pm    Post subject:
Reply with quote

Thanks for posting your resolution.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us