Can someone explain how do I fix my input to show the data correctly. I don't understand how it works. Can someone show me how the code should look ?
data hurricane1;
input name $ 1-7 year 8-12 deaths 13-17;
datalines;
Katrina 2005 1200
Andrew 1992 23
Charley 2004 10
Wilma 2005 5
Ivan 2004 25
Rita 2005 7
Frances 2004 6
Hugo 1989 21
Jeanne 2004 5
Floyd 1999 56
;
run;
proc print data=hurricane1;
run;
I really don't get how to use column inputs. What do I have to do ?
Your data have tabs. Use INFILE statement option EXPANDTABS;
data hurricane1;
infile cards expandtabs;
input name $ 1-7 year 8-12 deaths 13-17;
datalines;
Katrina 2005 1200
Andrew 1992 23
Charley 2004 10
Wilma 2005 5
Ivan 2004 25
Rita 2005 7
Frances 2004 6
Hugo 1989 21
Jeanne 2004 5
Floyd 1999 56
;
run;
proc print data=hurricane1;
run;
There's nothing wrong with your program, but you have tabs in your data rows causing misalignments. Remove ALL tabs from your data lines and replace with spaces.
No, you have tab characters between your data items: Katrina<tab>2005<tab>1200.
Remove the tabs or use @data_null__ 's solution.
Alternative would show the tabs some love. DSD and DLM= options.
data hurricane1;
infile cards dsd dlm='09'x;
input name $ year deaths;
datalines;
Katrina 2005 1200
Andrew 1992 23
Charley 2004 10
Wilma 2005 5
Ivan 2004 25
Rita 2005 7
Frances 2004 6
Hugo 1989 21
Jeanne 2004 5
Floyd 1999 56
;
run;
proc print data=hurricane1;
run;
Your data have tabs. Use INFILE statement option EXPANDTABS;
data hurricane1;
infile cards expandtabs;
input name $ 1-7 year 8-12 deaths 13-17;
datalines;
Katrina 2005 1200
Andrew 1992 23
Charley 2004 10
Wilma 2005 5
Ivan 2004 25
Rita 2005 7
Frances 2004 6
Hugo 1989 21
Jeanne 2004 5
Floyd 1999 56
;
run;
proc print data=hurricane1;
run;
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.