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;
Perhaps the first INPUT statement should read:
input XRPKLR 6 @;
Otherwise, you're getting the value starting at column 1.
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.
Change
IF XRPKLR LT 2 THEN DELETE;
to
if xrpklr >= 2;
and try it out.
Perhaps the first INPUT statement should read:
input XRPKLR 6 @;
Otherwise, you're getting the value starting at column 1.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.