BookmarkSubscribeRSS Feed
Dee4
Calcite | Level 5

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:

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data pig;
70 input BIRTHWT WEANWTgroup$sex$litter$ ;
71 datalines;
 
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
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.
 
81 CHAR 1.006975061.4.3.1.M.1
ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222
NUMR 1E00697506194E3919D9100000000000000000000000000000000000000000000000000000000000
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.898112 sex=0.952543 litter=1.006975 _ERROR_=1 _N_=2
NOTE: Invalid data for BIRTHWT in line 82 1-21.
NOTE: Invalid data for WEANWT in line 83 1-21.
 
86 CHAR 1.133980925.4.6.1.F.1
ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222
NUMR 1E13398092594E691969100000000000000000000000000000000000000000000000000000000000
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=1.315417 sex=1.133980 litter=1.133980 _ERROR_=1 _N_=3
NOTE: Invalid data for BIRTHWT in line 87 1-21.
NOTE: Invalid data for WEANWT in line 88 1-21.
 
91 CHAR 0.861825503.4.3.1.M.2
ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222
NUMR 0E86182550394E3919D9200000000000000000000000000000000000000000000000000000000000
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=1.406136 sex=0.816466 litter=0.861825 _ERROR_=1 _N_=4
NOTE: Invalid data for BIRTHWT in line 92 1-21.
NOTE: Invalid data for WEANWT in line 93 1-21.
 
96 CHAR 0.997903214.4.5.2.F.6
ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222
NUMR 0E99790321494E592969600000000000000000000000000000000000000000000000000000000000
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.893576 sex=0.902648 litter=0.997903 _ERROR_=1 _N_=5
NOTE: Invalid data for BIRTHWT in line 97 1-21.
NOTE: Invalid data for WEANWT in line 98 1-20.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
101 CHAR 0.90718474.4.8.2.M.5
ZONE 32333333330323030403222222222222222222222222222222222222222222222222222222222222
NUMR 0E9071847494E8929D95000000000000000000000000000000000000000000000000000000000000
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.952543 sex=0.902648 litter=0.907184 _ERROR_=1 _N_=6
NOTE: Invalid data for BIRTHWT in line 102 1-21.
NOTE: Invalid data for WEANWT in line 103 1-21.
 
106 CHAR 1.043262451.5.2.M.6
ZONE 32333333333030304032222222222222222222222222222222222222222222222222222222222222
NUMR 1E04326245195929D960000000000000000000000000000000000000000000000000000000000000
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.898112 sex=1.360777 litter=1.043262 _ERROR_=1 _N_=7
NOTE: Invalid data for BIRTHWT in line 107 1-19.
NOTE: Invalid data for WEANWT in line 108 1-19.
 
111 CHAR 1.224699399.5.2.2.M.5
ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222
NUMR 1E22469939995E2929D9500000000000000000000000000000000000000000000000000000000000
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=1.315417 sex=1.301810 litter=1.224699 _ERROR_=1 _N_=8
NOTE: Invalid data for BIRTHWT in line 112 1-21.
NOTE: Invalid data for WEANWT in line 113 1-21.
 
116 CHAR 1.406136347.5.5.2.M.5
ZONE 32333333333032303040322222222222222222222222222222222222222222222222222222222222
NUMR 1E40613634795E5929D9500000000000000000000000000000000000000000000000000000000000
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=1.456031 sex=1.451495 litter=1.406136 _ERROR_=1 _N_=9
NOTE: Invalid data for BIRTHWT in line 117 1-21.
NOTE: Invalid data for WEANWT in line 118 1-21.
NOTE: LOST CARD.
121 ;
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=1.360777 sex=1.351705 litter= _ERROR_=1 _N_=10
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.PIG has 9 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 671.09k
OS Memory 31460.00k
Timestamp 11/02/2022 02:30:21 CH
Step Count 139 Switch Count 2
Page Faults 0
Page Reclaims 91
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272
 
 
121 ;
122 run;
123
124 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
134
3 REPLIES 3
SASJedi
SAS Super FREQ

@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.
It looks like your program is skipping to a new line in the DATALINES each time it reads a variable on the INPUT statement:
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.  
Check out my Jedi SAS Tricks for SAS Users
Tom
Super User Tom
Super User

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.

Dee4
Calcite | Level 5
It works!!! Thank you so much!!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 3 replies
  • 431 views
  • 2 likes
  • 3 in conversation