BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fpascal
Quartz | Level 8

The IF statement should be removing the current observation less than 2 from the dataset.  That is not happening

===============================================

===============================================

FILENAME XR '/folders/myfolders/Data.txt' LRECL=29;

DATA WORK;
INFILE XR MISSOVER;
INPUT XRPKLR @;

IF XRPKLR LT 2 THEN DELETE;
LENGTH
SEQN 7
XRPKLR 8
XRPKLL 8
XRPOMFR 8
XRPOMFL 8
XRPOMTR 8
XRPOMTL 8
XRPOLFR 8
XRPOLFL 8
XRPOLTR 8
XRPOLTL 8
XRPSMFR 8
XRPSMFL 8
XRPSMTR 8
XRPSMTL 8
XRPSLFR 8
XRPSLFL 8
XRPSLTR 8
XRPSLTL 8
XRPCHOR 8
XRPCHOL 8
XRPJRR 8
XRPJRL 8
;
FORMAT
;
INPUT
SEQN 1-5
XRPKLR 6
XRPKLL 7
XRPOMFR 8
XRPOMFL 9
XRPOMTR 10
XRPOMTL 11
XRPOLFR 12
XRPOLFL 13
XRPOLTR 14
XRPOLTL 15
XRPSMFR 16
XRPSMFL 17
XRPSMTR 18
XRPSMTL 19
XRPSLFR 20
XRPSLFL 21
XRPSLTR 22
XRPSLTL 23
XRPCHOR 24
XRPCHOL 25
XRPJRR 26
XRPJRL 27
;
LABEL
SEQN = "Respondent identification number"
XRPKLR = "Kellgren-Lawrence score, right knee"
XRPKLL = "Kellgren-Lawrence score, left knee"
XRPOMFR = "Osteophyte - medial femoral, right knee"
XRPOMFL = "Osteophyte - medial femoral, left knee"
XRPOMTR = "Osteophyte - medial tibial, right knee"
XRPOMTL = "Osteophyte - medial tibial, left knee"
XRPOLFR = "Osteophyte - lateral femoral, right knee"
XRPOLFL = "Osteophyte - lateral femoral, left knee"
XRPOLTR = "Osteophyte - lateral tibial, right knee"
XRPOLTL = "Osteophyte - lateral tibial, left knee"
XRPSMFR = "Sclerosis - medial femoral, right knee"
XRPSMFL = "Sclerosis - medial femoral, left knee"
XRPSMTR = "Sclerosis - medial tibial, right knee"
XRPSMTL = "Sclerosis - medial tibial, left knee"
XRPSLFR = "Sclerosis - lateral femoral, right knee"
XRPSLFL = "Sclerosis - lateral femoral, left knee"
XRPSLTR = "Sclerosis - lateral tibial, right knee"
XRPSLTL = "Sclerosis - lateral tibial, left knee"
XRPCHOR = "Chondrocalcinosis - right knee"
XRPCHOL = "Chondrocalcinosis - left knee"
XRPJRR = "Joint replacement - right knee"
XRPJRL = "Joint replacement - left knee"
;
RUN;
PROC PRINT DATA=WORK;
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Perhaps the first INPUT statement should read:

 

input XRPKLR 6 @;

 

Otherwise, you're getting the value starting at column 1.

View solution in original post

6 REPLIES 6
Reeza
Super User

I think it's because you have a second input after the delete statement. 

 

If you want to conditionally input a line you need to change the logic to if VAR GE 2 then input the remaining records.

See a sample here under Full Code.

http://support.sas.com/kb/45/289.html

 

Or add the delete after your second input statement. 

 

It's an order of operations idea.

 

PS. Please only include the relevant code, log and output. It's hard to parse through that many pages to figure out what's going on.  

 

 

 

 

fpascal
Quartz | Level 8
Reeza. you have been so helpful to me. thank you but the correct solution was from user Astounding below. Until .....
fpascal
Quartz | Level 8
thanks for the effort. the user Astounding had the correct answer
Astounding
PROC Star

Perhaps the first INPUT statement should read:

 

input XRPKLR 6 @;

 

Otherwise, you're getting the value starting at column 1.

fpascal
Quartz | Level 8
This worked. Excellent. I knew this was the answer when I read it.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1033 views
  • 1 like
  • 4 in conversation