BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Godzilla_Hat
Obsidian | Level 7

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;

Screenshot 2021-09-30 132909.png

I really don't get how to use column inputs. What do I have to do ?

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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;

 Screenshot 2021-09-30 154537.png

View solution in original post

6 REPLIES 6
SASKiwi
PROC Star

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.

Godzilla_Hat
Obsidian | Level 7
So are the tabs for example the "1-7" ?
SASKiwi
PROC Star

No, you have tab characters between your data items: Katrina<tab>2005<tab>1200.

Remove the tabs or use @data_null__ 's solution.

data_null__
Jade | Level 19

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;
Godzilla_Hat
Obsidian | Level 7
Thank you ! I was able to get it to work !
data_null__
Jade | Level 19

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;

 Screenshot 2021-09-30 154537.png

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 6 replies
  • 779 views
  • 4 likes
  • 3 in conversation