Is there any good examples of using basic to create records? I am totally lost.
My problem is to create multiple records based on the input record. Assume there are two columns, start date and end date. I need to create a row with the month and days used.
Why do you want to use basic to do this? Design a server job and use a SEQuential stage to read your INPUT and pass the data through a transformer to the OUTPUT SEQ stage. Within the transformer you can do whatever you want with the data. You would probably end up using Iconv/Oconv and Trimb.
but, if you insist on Basic, you would do something like (very basic):
Inbetween you would define the layout and still do Iconv/Oconv. This is very much an outline of what would have to be done. the devil is in the detail - like the layout, a few if then elses (like checking if file exists). The Help explains the Open/Read/Write. It should put you on the right track. good luck
dnzl
"what the thinker thinks, the prover proves" - Robert Anton Wilson
I think you are correct, this is a good solution for BASIC. How would you do this in SAS?
Another solution is to create a table of days or use a day dimension table. Join this input table to the new day table and count how many records you get by month.
kduke wrote:
Another solution is to create a table of days or use a day dimension table. Join this input table to the new day table and count how many records you get by month.
thats a good idea. i just looked at the output again - its not that simple for a server job design! phew!
dnzl
"what the thinker thinks, the prover proves" - Robert Anton Wilson
Thanks for the suggestions. I was able to get it to work.
I wrote a routine that would write to a hash file created/cleared beforehand. I had some trouble getting the routine calls to work, but the forum helped to explain the catalog.
That's actually quite a different problem, but solved fairly easily using an intermediate text file and generating the same number of line terminators as there are in your count column.
You need to be careful to specify no formatting in the Inputs tab for the Sequential File stage; when you read from the text file, the terminator characters that you wrote will become extra lines.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod wrote:intermediate text file and generating the same number of line terminators as there are in your count column.
Can I use a transformer to read the two fields and write to 1 field with the line terminators? I'm stuck on how to write the number of terminators based on the count field. I don't recall any for loops can be done in the transformer.
Yes, you use a Transformer, but almost certainly use a Routine to generate the single output column based on the input columns, which are arguments to the routines.
If you just wanted empty rows you could use Str(Stuff:Char(10),Counter) but for anything much more complex a Routine is indicated. The return value from that routine becomes the derived value for the output column.
Last edited by ray.wurlod on Wed Apr 06, 2005 12:03 am, edited 2 times in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
FUNCTION GenerateOutputLine(Arg1, Arg2, Arg3, Arg4, Counter)
* Generates as many tab-delimited output lines as Counter indicates
EQUATE TAB To Char(9)
If System(91)
Then
Terminator = Char(10):Char(13) ; * DOS
End
Else
Terminator = Char(10) ; * UNIX
End
If Num(Counter)
Then
Ans = ""
For LineNo = 1 To Counter
Line = Arg1 : TAB : Arg2 : TAB : Arg3 : TAB : Arg4 : Terminator
Ans := Line
Next LineNo
End
Else
Ans = @NULL
Call DSLogWarn("Non-numeric Counter argument", "GenerateOutputLine")
End
RETURN(Ans)
Last edited by ray.wurlod on Wed Apr 06, 2005 12:05 am, edited 2 times in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.