<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reading Raw Data over two lines using a conditional IF statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354911#M273986</link>
    <description>&lt;P&gt;Here is a clearer screen capture of the error of the data (how I am not skipping a line).&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8648i4075700530FD1F01/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="ErrorOnSkipLine.JPG" title="ErrorOnSkipLine.JPG" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 01 May 2017 13:24:38 GMT</pubDate>
    <dc:creator>Pete_Murphy</dc:creator>
    <dc:date>2017-05-01T13:24:38Z</dc:date>
    <item>
      <title>Reading Raw Data over two lines using a conditional IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354908#M273985</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;I am teaching myself SAS through working through some books, right now I am stuck on a question from The Little SAS Book Exercises and Projects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't work out why my below code is not working, I realise this is probably a simple question but I have spent the last hour and a half trying to work this out for myself and can't make progress so I am turning once again tot he SAS community for help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do is read in raw data that each observation is over two lines of the raw data file. I did this fine but the next part of my requirement is to only read in specific data, in this case when the Classification_Group variable is not equal to 'student'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem seems to be that I can successfully use the IF.... THEN ....DELETE format but I can't seem to work out how to tell SAS to skip a line when deleteing a line from the input statement. It seems that SAS deletes the input but goes to the very next line rather than doing what I want it to do and skip the rest of the ovservation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is probably best I use an example, below is a little cut and paste from my data file:&lt;/P&gt;&lt;PRE&gt;35    Faculty  ROBIN  MURRAY
      email:robin.murray@csu.edu  phone:555-4389  PHYS
36    Student  DAWN  CUNNINGHAM
      email:dawn.cunningham@csu.edu  phone:555-8747  MATH
37    Faculty  JAMIE  BRADLEY
      email:jamie.bradley@csu.edu  phone:555-8784  MCRO&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is read in observation 35 as it has the value Faculty but skip observation 36 as it has the value of Student but read atain observation 37.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code.&lt;/P&gt;&lt;PRE&gt;Data ComputerUsers;
	INFILE '/folders/myfolders/TheLittleSASBook/CodePractice/Chapter02/Data/CompUsers.txt'
		OBS = 80
		;
	INPUT 	User_Id Classification_Group $ @;
				IF Classification_Group = 'Student' THEN DELETE;
				INPUT	First_Name :$20.
						Last_Name :$20.
						#2 @'email:' Email_Address :$35.
						@'phone:' Campus_Phone_Number :$15.
						Department $;
				
PROC PRINT DATA = computerusers;
RUN;&lt;/PRE&gt;&lt;P&gt;I don't actually get any errors with my code, or any warnings but there are some comments that raise alarm bells.&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;NOTE: SAS went to a new line when INPUT @'CHARACTER_STRING' scanned past the end of a line.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;I attach my raw data file.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Below is a screen capture of how my data goes wrong.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8647iEC092A847CDA6E08/image-size/medium?v=1.0&amp;amp;px=-1" border="0" alt="ErrorOnSkipLine.JPG" title="ErrorOnSkipLine.JPG" width="565" height="128" /&gt;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;There is a hint provided for the question as well:&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&lt;EM&gt;Hint: For the rows of data for students, think about how to tell SAS to skip a line and remove the observation&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;I can't seem how to do both 'skip a line' and remove the observation, I tried using multiple if statements but could not get it to work.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;And finally I am using SAS University Edition on a Windows 10 Machine.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Once again many thanks in advance for any assistance anyone can give me.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Pete&lt;/DIV&gt;</description>
      <pubDate>Mon, 01 May 2017 13:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354908#M273985</guid>
      <dc:creator>Pete_Murphy</dc:creator>
      <dc:date>2017-05-01T13:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Raw Data over two lines using a conditional IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354911#M273986</link>
      <description>&lt;P&gt;Here is a clearer screen capture of the error of the data (how I am not skipping a line).&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8648i4075700530FD1F01/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="ErrorOnSkipLine.JPG" title="ErrorOnSkipLine.JPG" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 13:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354911#M273986</guid>
      <dc:creator>Pete_Murphy</dc:creator>
      <dc:date>2017-05-01T13:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Raw Data over two lines using a conditional IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354917#M273987</link>
      <description>&lt;P&gt;Your first INPUT statement only read one line, but there are two lines per observation.&lt;/P&gt;
&lt;P&gt;You could try adding the #2 tag to both of your INPUT statements .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INPUT #1 User_Id Classification_Group $ #2 @;
...
INPUT #1 First_Name :$20. Last_Name :$20.
      #2 @'email:' Email_Address :$35. 
         @'phone:' Campus_Phone_Number :$15. Department $
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 May 2017 13:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354917#M273987</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-01T13:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Raw Data over two lines using a conditional IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354946#M273988</link>
      <description>&lt;P&gt;You can also make a slight change to your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	INPUT 	User_Id Classification_Group $ @;
		IF Classification_Group = 'Student' THEN DO;
                      DELETE; input ;  delete;  
                END; else do;
		     INPUT	First_Name :$20.
				Last_Name :$20.
			#2 @'email:' Email_Address :$35.
				@'phone:' Campus_Phone_Number :$15.
				Department $;
               end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 May 2017 14:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354946#M273988</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-01T14:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Raw Data over two lines using a conditional IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354998#M273989</link>
      <description>Thanks Tom,&lt;BR /&gt;I would say "I can't believe it was that easy" but I actually knew it was going to be something as simple as that. I just couldn't figure it out for myself and spent quite some time trying.&lt;BR /&gt;&lt;BR /&gt;The solution from Shmuel below is also quite interesting, more complex but interesting as well. (Thanks to Shmuel too).</description>
      <pubDate>Mon, 01 May 2017 17:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Raw-Data-over-two-lines-using-a-conditional-IF-statement/m-p/354998#M273989</guid>
      <dc:creator>Pete_Murphy</dc:creator>
      <dc:date>2017-05-01T17:57:33Z</dc:date>
    </item>
  </channel>
</rss>

