Here is my code: (please let me know what is wrong with it, the data cannot correctly be import).
data pig;
input BIRTHWT WEANWT group$ sex$ litter$ ;
datalines;
0.771107029 3.2 1 M 1
0.793786648 3.4 1 F 3
0.807394419 3.6 1 F 2
0.816466266 3.8 1 F 2
0.839145885 3.9 1 M 2
0.884505122 4 1 M 2
0.90718474 4.1 1 M 3
0.898112893 4.1 1 M 3
0.952543977 4.2 1 F 1
1.006975061 4.3 1 M 1
0.961615824 4.4 1 M 2
1.043262451 4.4 1 M 3
1.315417873 4.5 1 M 2
1.133980925 4.6 1 M 3
1.133980925 4.6 1 F 1
1.179340162 4.6 1 F 1
1.451495584 5.6 1 F 2
1.406136347 5.7 1 M 3
0.816466266 4 1 M 1
0.861825503 4.3 1 M 2
0.861825503 4.3 1 M 2
0.898112893 4.4 1 F 1
0.893576969 4.4 1 F 3
0.902648816 4.5 2 F 4
0.997903214 4.5 2 F 6
1.043262451 4.6 2 M 6
0.90718474 4.7 2 M 6
0.952543977 4.7 2 M 4
0.902648816 4.7 2 F 4
0.90718474 4.8 2 M 5
0.816466266 4.8 2 F 5
0.807394419 4.8 2 F 5
0.898112893 4.8 2 M 5
1.36077711 5 2 F 4
1.043262451 5 2 M 6
1.133980925 5 2 M 6
1.179340162 5 2 F 4
1.315417873 5.1 2 F 4
1.301810102 5.1 2 M 4
1.224699399 5.2 2 M 5
1.084085764 5.2 2 M 5
1.451495584 5.2 2 M 6
1.456031508 5.3 2 M 6
1.451495584 5.5 2 M 6
1.406136347 5.5 2 M 5
1.587573295 5.6 2 M 4
1.451495584 5.6 2 M 5
1.36077711 5.6 2 F 4
1.351705263 6.3 2 M 4
;
run;
%include "/home/u60798883/sasuser.v94/danda.sas";
%reg(pig,WEANWT,BIRTHWT);
And then the log showing notes like this:
@Dee4 From your log:
76 CHAR 0.839145885.3.9.1.M.2 ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222 NUMR 0E83914588593E9919D9200000000000000000000000000000000000000000000000000000000000 NOTE: Invalid data errors for file CARDS occurred outside the printed range. NOTE: Increase available buffer lines with the INFILE n= option. BIRTHWT=. WEANWT=. group=0.807394 sex=0.816466 litter=0.839145 _ERROR_=1 _N_=1 NOTE: Invalid data for BIRTHWT in line 77 1-19. NOTE: Invalid data for WEANWT in line 78 1-20.
data pig;
input BIRTHWT WEANWT group$ sex$ litter$ ;
datalines;
0.771107029 3.2 1 M 1
0.793786648 3.4 1 F 3
0.807394419 3.6 1 F 2
0.816466266 3.8 1 F 2
0.839145885 3.9 1 M 2
0.884505122 4 1 M 2
0.90718474 4.1 1 M 3
When I run this code in the SAS Windowing Environment (9.4 M7) the data reads in just fine for me. To further troubleshoot, re-run just the DATA step using the TRUNCOVER option to prevent the input statement going to another line for more data:data pig;
input BIRTHWT WEANWT group $ sex $ litter $ TRUNCOVER;
datalines;
0.771107029 3.2 1 M 1
0.793786648 3.4 1 F 3
0.807394419 3.6 1 F 2
0.816466266 3.8 1 F 2
0.839145885 3.9 1 M 2
0.884505122 4 1 M 2
0.90718474 4.1 1 M 3
;
I don't think that will fix the problem, but it should help diagnose the issue. If the DATALINES were copied and pasted into the program from a source that was not plain text, there may be unprintable embedded characters causing issues. Read the messages in the log, they should help you understand what is happening.
Pasting the text into the body of you message instead of using the Insert Code or Insert SAS Code icons scrabbles it a little, but we can probably still figure out what it is saying.
NOTE: Invalid data for BIRTHWT in line 72 1-21. NOTE: Invalid data for WEANWT in line 73 1-21. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 76
CHAR 0.839145885.3.9.1.M.2 ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222 NUMR 0E83914588593E9919D9200000000000000000000000000000000000000000000000000000000000
So it looks like you text file has tab characters ('09'x) between the values instead of the spaces that you told SAS to look for.
Try adding an INFILE statement so you can tell SAS to look for the tabs. You should probably also add the DSD option in case there are any missing values that are represented in the file by two adjacent tabs. You should also add the TRUNCOVER option so that you can prevent the other issue the log is showing:
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
You could point the INFILE at the in-line data:
data pig;
infile datalines dsd dlm='09'x truncover;
input BIRTHWT WEANWT group $ sex $ litter $ ;
datalines;
But if your source data file has tabs between the values you probably should NOT paste the lines into the program editor as then they might be replaced with spaces. Better to store the data in its own file and point the INFILE statement at that file.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Ready to level-up your skills? Choose your own adventure.