Copy only the last record from input to output.
Copy only the last record from input to output.
Hi,
I have a VBS file from which I need to get the first record and last record in the output file. I used STOPAFT=1 but it helps to get the first record. But I am not sure how to get the last record only.
Can you please tell me how to get only the last record from a VBS file using SORT.
Thanks,
I have a VBS file from which I need to get the first record and last record in the output file. I used STOPAFT=1 but it helps to get the first record. But I am not sure how to get the last record only.
Can you please tell me how to get only the last record from a VBS file using SORT.
Thanks,
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Copy only the last record from input to output.
Use JOINKEYS with the same dataset. JOIN UNPAIRED,F1,F2,ONLY. REFORMAT statement including the entire F1 and F2 and the match-markers (?). Depending on value of match-marker, BUILD correct output.The key for the JOINKEYS is an extension to the record containing a sequence number (large enough to be unique for each record in the file). This will be set in the JNFnCNTL files. For one sequence number use START=0, for the other use START=1.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Copy only the last record from input to output.
Or, for less code and excitement, look at ICETOOL's SUBSET operator.
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Copy only the last record from input to output.
Or even OUTFIL NODETAIL with TRAILER
zprogrammer
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Copy only the last record from input to output.
Yes, like this:
The other two are more flexible, as different numbers of "first" and "last" records could be processed (or ignored).
Code: Select all
OUTFIL HEADER1=(1,80),
TRAILER1=(1,80),
REMOVECC,
NODETAIL
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute