Look very closely at this line
42 m white nevermarried college4yearsormore verygood verygood veryactive never 27.3 28.58
Count how many spaces between values there are.
Your INPUT statement is reading 12 variables. Which means that there needs to be 11 spaces between the values read.
This line is the source of the "NOTE: SAS went to a new line when INPUT statement reached past the end of a line." When you look at your data set you will see that the Satis variable has the value of 35 read from the age of the next (and since that line was used for this one there is no data for that record as the INPUT statement then reads the line after that.
The Truncover option on the INFILE will stop reading when the items on the input statement exceed the values of the datalines read. So is one way and will have SATIS as missing. Or provide a value or . to read as missing.
Please share your code as text via the running man icon
and not a screen-shot so we can actually run it.
Add TRUNCOVER to you datalines statement.
And for this one actually running your code would make debugging much easier than looking at your screen-shot.
please see below
Libname Lifechar '/home/u61727912/sasuser.v94/dylan mod 1' ;
Run ;
Data lifechar;
infile datalines;
input age sex $ race $ marital $ educ $ health $ diet $ activity $ smoker $ bmi bmi2 satis $ ;
If age > 65 then agedef = 'elder';
else agedef = 'young' ;
datalines ;
52 m white married college4yearsormore good good notveryactive never 30.0 27.43 verysat
61 m black married grade12orged good verygood veryactive never 26.6 27.98 somewhatsat
. f other married grades9through11 excellent good veryactive never 19.5 19.01 verysat
30 m black married college4yearsormore excellent excellent veryactive never 22.8 20.92 somewhatsat
50 m white memberofunmarriedcouple college4yearsormore verygood fair veryactive former 26.8 25.62 somewhatsat
52 f black nevermarried grade12orged good excellent notactiveatall . . . verysat
28 f black nevermarried college1to3years excellent fair somewhatactive never 22.7 24.56 verydissat
62 m white nevermarried college4yearsormore verygood verygood somewhatactive never 28.7 25.38 verysat
18 f black nevermarried grade12orged excellent fair somewhatactive never 27.4 26.81 verysat
48 f black married college4yearsormore fair good somewhatactive former 33.8 31.92 verysat
66 m white divorce grade12orged good good somewhatactive former 26.6 24.27 verysat
75 f white nevermarried college4yearsormore good fair somewhatactive former . . verysat
64 m white married college4yearsormore verygood excellent somewhatactive . 25.8 27.80 verydissat
42 m white nevermarried college4yearsormore verygood verygood veryactive never 27.3 28.58
35 m white married college4yearsormore verygood verygood somewhatactive never 29.6 29.63 somewhatdissat
23 m white nevermarried college4yearsormore verygood verygood somewhatactive never . . somewhatsat
50 m white nevermarried college4yearsormore good verygood veryactive never 24.2 22.89 verysat
46 f white memberofunmarriedcouple college4yearsormore good verygood somewhatactive never 23.2 23.01 somewhatsat
43 f white married college4yearsormore verygood good somewhatactive former . . somewhatdissat
45 f black nevermarried college4yearsormore verygood good somewhatactive never 20.7 18.30 verysat
84 f hispanic separated grade1through8 fair fair notveryactive never 22.1 22.75 verydissat
36 f hispanic memberofunmarriedcouple grades1through8 good fair somewhatactive never 31.4 31.14 verysat
85 m white married college4yearsormore fair fair somewhatactive never 27.9 26.77 verysat
60 f api widowed grade12orged fair fair notveryactive never 24.8 26.18 verydissat
50 m white memberofunmarriedcouple college4yearsormore verygood good notveryactive former 20.3 20.06 verysat
45 m hispanic nevermarried college4yearsormore fair fair somewhatactive never 39.3 37.46 verysat
77 f black widowed college1to3years verygood verygood veryactive former 31.6 29.55 verysat
55 f white divorce college4yearsormore verygood verygood veryactive former 20.6 22.85 verysat
49 f black nevermarried grades9through11 good verygood somewhatactive current 29.7 29.53 somewhatsat
59 f hispanic divorce college4yearsormore good good notveryactive former 33.3 31.68 verysat
;
proc print;
run;
Look very closely at this line
42 m white nevermarried college4yearsormore verygood verygood veryactive never 27.3 28.58
Count how many spaces between values there are.
Your INPUT statement is reading 12 variables. Which means that there needs to be 11 spaces between the values read.
This line is the source of the "NOTE: SAS went to a new line when INPUT statement reached past the end of a line." When you look at your data set you will see that the Satis variable has the value of 35 read from the age of the next (and since that line was used for this one there is no data for that record as the INPUT statement then reads the line after that.
The Truncover option on the INFILE will stop reading when the items on the input statement exceed the values of the datalines read. So is one way and will have SATIS as missing. Or provide a value or . to read as missing.
THank you so much!!!!!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.