On Sep 19, 1:28 am, "Rune Runnestø" <r...@fastlane.no> wrote: Hi! I figure that if I could write a macro and let the start of each file that are being processed during the execution of a program telling the user which file SAS is processing at the moment, then it would make it easier to find and debug the program when errors or warnings occur. It doesn't necessarily have to be a macro
This is how I might to it. 1) You don't need need all those infile options and 2) to replace single character TRANSLATE is the best function choice. 3) You can count the tabs in each line with COUNT function. This method updates the file in place which is slightly more efficient. The first data step just makes some fixed length data with tabs. You can ignore that. filename dok 'dok.dat'
I think if you want to use the same infile / file, you have to split it in two parts with a temporary SAS ds: filename xx "whatever.csv"; data a; length a $200; /* or longer, depending on the CSV-file. */ infile xx; input; a = _infile_; if 1 then output; run; data _null_; set a; file xx; put a; run; Gerhard On Tue, 26 Aug 2008 08:00:46 -0400, Don Henderson
Again, this is just illustrative code that may or may-not help Rune with her problem. Uses colon and space delimiters to id label/value pairs. data _null_; infile cards delimiter = ': '; retain bu -1; input @; scs = count(_infile_, ':'); do i = 1 to scs; input label :$&32. value :$&32. @; put label +bu ': ' value +4 @; if label =: 'Label X' then do; input value
Rune mentions not what result is desired when the condition "label of the first data value is 'ARKIV:'" is absent, but an illustration of column input etc might be helpful: data _null_; input f1 $1-6 f2 $8-12 f3 $17-34; label = ifc(f1 =: 'ARKIV:', 'ARKIV TEKST:', ' '); put f1 $1-6 f2 $8-12 label $17-34 f3 $35-50;; cards; ARKIV: A Text string nr. 1 ARKIV: A 11 Text