View previous topic :: View next topic
|
Author |
Message |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Dear All,
Let me clarify my requirement. Please refer to the sample data below.
Code: |
JAN RC RC FLAG ACCNT AC FLAG COMBINATION COMB FLAG
000000900 10000001 NONE 9399999 ERROR 100000019399999 NONE
000000900 10000001 NONE 9399999 NONE 100000019399999 ERROR
000130500 10000001 NONE 1420500 ERROR 100000011420500 NONE
000130500 10000001 NONE 1420500 NONE 100000011420500 ERROR |
I need the above data to be written into an output file as below.
Code: |
JAN RC RC FLAG ACCNT AC FLAG COMBINATION COMB FLAG
000000900 10000001 NONE 9399999 ERROR 100000019399999 ERROR
000130500 10000001 NONE 1420500 ERROR 100000011420500 ERROR |
Code'd
Please let me know if this could be acheived using Mainframe SAS? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes it can*.
If it is urgent, you should get on with it straight away.
If you want help on a forum, the last thing you should do is ask for URGENT. 2nd-last thing is ask someone to do the work for you. 3rd-last thing is ask a question which can be yes/no. 4th-last thing is ask a dumb question. Etc. Rearrange to suit. Possibly with SAS.
*I have no idea about SAS, but it looks simple enough. If really URGENT, I'd do it with the editor. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
URGENT
There you go, I've replied URGENT |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
It certainly can be done with SAS -- the LAG1 function might come in handy. However, since you did not provide any clue as to what the rules are for getting the input file to look like the output file, there's not much ANYBODY on this forum could do to help.
Since this is so urgent, I strongly recommend you stop looking at forum posts and start coding SAS. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Yes it can but as you haven't bothered to tell us anything about how the data is selected or anything else, we'll just have to wait until you can be bothered to tell us anything useful.
Please also post your own attempt at this problem and where you have encountered errors |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Quote: |
COBOL,JCL,Mainframe SAS,VSAM,MCAR,MFS,PLI,COBOL - IMS-DB,DB2 |
You can do it in Cobol, PL/I. Or your Sort product, rexx... Maybe stick it into an IMS or DB2 database and extract it from there.
Requirement, after clarification, is obviously to keep the headings and then include all the even-numbered data records.
Since you have VSAM as one of your skills, how about having a go at the recent Interview Question, once this urgent thing is out of the way.
And use the Code tags when you around to providing something useful... |
|
Back to top |
|
|
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Hello All,
Well, I am being more specific to claify the requirement.
My Input File (attached) is sorted on the Field JAN. I give below the first 2 records of the Input File.
JAN RC RC FLAG ACCNT AC FLAG COMBINATION COMB FLAG
000000900 10000001 NONE 9399999 ERROR 100000019399999 NONE
000000900 10000001 NONE 9399999 NONE 100000019399999 ERROR
For the JAN 000000900,
RC FLAG = 'NONE', AC FLAG = 'ERROR' and COMB FLAG = 'NONE' (for the 1st record)
RC FLAG = 'NONE', AC FLAG = 'NONE' and COMB FLAG = 'ERROR' (for the 2nd record)
So, what I would need to do is to create a single JAN 000000900 with
RC FLAG = 'NONE', AC FLAG = 'ERROR' and COMB FLAG = 'ERROR'.
I would be able to code it easily in COBOL. But, I need to code it in SAS. How could this be achieved using SAS? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
1) DO NOT post attachments as not everyone has the access to open them, and others like me can not be arsed to open them.
2) You have still not set out clearly the selection criteria
I suggest you expain in detail why the records being created are to be created, we know absolutely nothing of the selction criteria.
Also, please post your own code so that we can see that you are making some effort without having your PAID job done for you |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You have "explained" nothing. Under what conditions will your single output record have AC FLAG='ERROR'? Under what conditions will your single output record have COMB FLAG='ERROR'? Are there any other values for RC FLAG besides 'NONE'? If so, what do you want the output value to be for each possible combination of input values? Can AC FLAG or COMB FLAG have values other than 'NONE' or 'ERROR'? If so, how do you want these other values handled in the output record? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Post subject: IMPORTANT - Require an urgent Reply. |
what kind of idiotic title is that ?
from the TS profile
Quote: |
Occupation: IT Professional
Mainframe Skills: COBOL,JCL,Mainframe SAS,VSAM,MCAR,MFS,PLI,COBOL - IMS-DB,DB2
|
since the gentleman qualifies as SAS skilled no reason for anybody to waste time replying :evil
edited to add a further comment
any reason for anybody willing to answer to go thru the 3000 lines of the attachment ? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So,
Code: |
each input record
If new key
output saved record
save record
exit
end-if
for each flag
If flag on current record = "NONE"
replace flag on current record by flag on previous record
end-if
end-for
save record
|
Remember that you have one left to do at the end of the input file (potentially, depending on later answers). Deal with the first record in the usual way. Consider what you actually want to do with single keys and with > 2 keys.
PS. I don't think the above is in SAS, but I'm sure it can deal with such logic. Possibly more succinctly than this, even. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Now that you have been thoroughly "beat up", suggest you consider this a different kind of learning. One thing that must be developed is the ability to ask clear questions, providing enough detail so that someone can help. . .
Forums do not "do" urgent . . .
Quote: |
I would be able to code it easily in COBOL. But, I need to code it in SAS. |
Why must this be SAS? Just curious. . . SAS is surely not a business requirement. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
So...
For a given key, combine to one record.
Check all occurrences of a flag, and if ANY of them are "error" within that key, then set that flag as "error" on the combined record????
If I had to what you are doing, I would use SORT. Take each record and replace "ERROR" with "00001" and replace "NONE" with "00000" (notice the five zeroes for each one).
Then, do a sort on the key field and a sum on all three of the flag fields. That way, if a given flag within a key value only has "NONE", the result record will have "00000" in that position. If it had ANY "ERROR" flags, then there will be something besides "00000" in that position.
Then, copy that file back through and change all "00000" to "NONE " and anything else, change it to "ERROR".
No program needed, no SAS needed, just a lot of trial and error getting the SORT steps set up.
Now, if you are really just a troll, trying to get the board worked up, then congrats, you got me. Otherwise, I wish you good luck in getting this working on your own. Whatever you do, DON'T post again asking someone to give you the sort steps needed to make this happen. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
After making own 'convenient' assumptions to all the questions by Robert,
You can try this code & modify to your needs,
Code: |
<A DATASTEP TO READ THE EXTERNAL FILE>
<SORT STEP IF NECESSARY>
THEN
DATA OUTDATASET;
SET INDATASET; BY JAN;
RETAIN AC_FLAG2 COMB_FLAG2; DROP AC_FLAG2 COMB_FLAG2;
IF FIRST.JAN THEN DO;
AC_FLAG2 = 'NONE'; COMB_FLAG2 = 'NONE';
END;
IF AC_FLAG = 'ERROR' THEN AC_FLAG2 = 'ERROR';
IF COMB_FLAG = 'ERROR' THEN COMB_FLAG2 = 'ERROR';
IF LAST.JAN THEN DO;
AC_FLAG = AC_FLAG2; COMB_FLAG = COMB_FLAG2; OUTPUT;
END;
RUN; |
Hope it helps. |
|
Back to top |
|
|
|