Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input statement

Status
Not open for further replies.

RicoQQ

Programmer
Feb 9, 2009
3
NO
Hi,

I have an issue with my input statement. I am trying to read a whole line in one variable. This is to do some fixing on a file. I do not have fixet length, and it can be long.

My problem is when input meets a double blank space, then it simply stops. I have used input @@ trying to get the whole lone. Is there another way?

My task is actually simple. I check every line by the first character. If it is a # then I want to write the line, if it is any other character as the first character, then I want to append it to the previous line.This shall make a file with lines starting with # and only that. Anyone knows a simple way to do this?
 
Hi Rico,

As the double spaces are giving you a problem, how about explicitly specifying an unlikely character as a delimiter?

You can then use a loop and an extra variable to store the concatenated string.

HTH

Code:
data want(keep=r) ;
   length s $50 r $200 ;
   infile cards dlm='*' ;
   do until (first(s) ne '#') ;
      input s :$50. ;
      r = catx(' ', r, s) ;
      end ;
   cards ;
#line begins with  hash
second  line doesn't 
#next line beginning with hash
final line  has  double  spacing
;;;;
proc print ;
   run ;

 
Thanks for answering.

I couldn't make the answer to work.
Maybe I was a little fast in telling my problem. I'll try to do it better.

this is an outcast of the file;
#12345##Ï#E#Ï#text#text2 #Very long text #abc#123#
#12345##Ï#E#Ï#text#text2 #Very long text #abc#123#
#12345##Ï#E#Ï#text#text2 #Very long text#abc#123#
#12345##Ï#E#Ï#text#text2 #Very long text #abc#123#

My problem is that the "very long text" can be over serveral lines.Empty lines and I have many spaces some places. And sometimes the line starts with #abc#123#. And if you look at the file that should be at the end. I want to correct that so I get one line in the outfile with lines like I pasted over.

So I thought the easiest way was to read it all into one variable that I could take some sustr to check it. But I cant read the entire line in one record. It wont read past doubble spaces.

Any idea?


 
Here I paste the problems:

#00000000001#Ï#E#Ï#OLFDIVDAVSPC#Ï#OLHPSKOOGMPB#Ï#COOP#Ï1999-07-01-12.00.00.000000Ï#KONV#Ï#KONVOSLO#ÏÏ#N#Ï#1000#Ï#0013#
#00000000003#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#CMNT#Ï1999-07-01-12.00.00.000000Ï#KONV#Ï#KONVOSLO#Ï#O 001: Here
is a
very long
text I had to remove as it was very long


#00000000004#Ï#E#Ï#OLRTCVAPNNHE#Ï#OLGOSQYLOSGK#Ï#CMNT #Ï1999-07-01-12.00.00.000000Ï#KONV#Ï#KONVOSLO#Ï#O 001: ENG.PREMIE=252.751#Ï#N#Ï#1000#Ï#0023#


#00000000005#Ï#E#Ï#OLFDIVDAVSPC#Ï#OLHPSKOOGMPB#Ï#CMNT#Ï1999-07-01-12.00.00.030064Ï#KONV#Ï#KONVOSLO#ÏÏ#N#Ï#1000#Ï#0013#
#00000000006#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#CMNT#Ï1999-07-01-12.00.00.030064Ï#KONV#Ï#KONVOSLO#ÏÏ#N#Ï#1000#Ï#0018#
#00000000008#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#COOP#Ï1999-07-01-12.00.00.030293Ï#KONV#Ï#KONVOSLO#Ï# Here is another one I had to remove.#Ï#S#Ï#1000#Ï
#0018#

#00000000010#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#COOP#Ï1999-07-01-12.00.00.032301Ï#KONV#Ï#KONVOSLO#Ï#O 001: And a third one


And this is how I want it;

#00000000001#Ï#E#Ï#OLFDIVDAVSPC#Ï#OLHPSKOOGMPB#Ï#COOP#Ï1999-07-01-12.00.00.000000Ï#KONV#Ï#KONVOSLO#ÏÏ#N#Ï#1000#Ï#0013#
#00000000003#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#CMNT#Ï1999-07-01-12.00.00.000000Ï#KONV#Ï#KONVOSLO#Ï#O 001: Here is a very long text I had to remove as it was very long
#00000000004#Ï#E#Ï#OLRTCVAPNNHE#Ï#OLGOSQYLOSGK#Ï#CMNT#Ï1999-07-01-12.00.00.000000Ï#KONV#Ï#KONVOSLO#Ï#O 001: ENG.PREMIE=252.751#Ï#N#Ï#1000#Ï#0023#
#00000000005#Ï#E#Ï#OLFDIVDAVSPC#Ï#OLHPSKOOGMPB#Ï#CMNT#Ï1999-07-01-12.00.00.030064Ï#KONV#Ï#KONVOSLO#ÏÏ#N#Ï#1000#Ï#0013#
#00000000006#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#CMNT#Ï1999-07-01-12.00.00.030064Ï#KONV#Ï#KONVOSLO#ÏÏ#N#Ï#1000#Ï#0018#
#00000000008#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#COOP#Ï1999-07-01-12.00.00.030293Ï#KONV#Ï#KONVOSLO#Ï# Here is another one I had to remove.#Ï#S#Ï#1000#Ï#0018#
#00000000010#Ï#E#Ï#OLPRYXUQYSFF#Ï#OLHFECTTWPUY#Ï#COOP#Ï1999-07-01-12.00.00.032301Ï#KONV#Ï#KONVOSLO#Ï#O 001: And a third one



So all lines should start in the same pattern as you can see.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top