Hello again, 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. 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. 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'. 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. It is probably best I use an example, below is a little cut and paste from my data file: 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 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. Here is my code. 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; I don't actually get any errors with my code, or any warnings but there are some comments that raise alarm bells. NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: SAS went to a new line when INPUT @'CHARACTER_STRING' scanned past the end of a line. I attach my raw data file. Below is a screen capture of how my data goes wrong. There is a hint provided for the question as well: Hint: For the rows of data for students, think about how to tell SAS to skip a line and remove the observation 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. And finally I am using SAS University Edition on a Windows 10 Machine. Once again many thanks in advance for any assistance anyone can give me. Pete
... View more