BookmarkSubscribeRSS Feed
marianhabesland
Calcite | Level 5

The raw data displayed below contains values for the following variables:

  • League (Character)
  • Team (Character)
  • Wins (Numeric)
  • Losses (Numeric) 

Write a DATA step that reads in the value for League, tests it, keeps only observations with a value of ‘American’, and produces an output data set containing all 4 variables.

 

This is my code so far:

data WORK.Illus;
infiles datalines delimiter = ' ';
input League $8. @;
if League = 'American';
input Team $18.
Wins 2
Losses 2;
datalines;
National New York Mets 19 12
American Toronto Blue Jays 19 13
American Boston Red Sox 17 12
National St Louis Cardinals 13 11

;

 

This is all I get in my table. What can I do to actually get the data I need in the table?

Screen Shot 2017-09-26 at 18.02.48.png

 

2 REPLIES 2
WarrenKuhfeld
Ammonite | Level 13
Remove both 2's. You do not want to read from column 2.
Wins 2
Losses 2;
Tom
Super User Tom
Super User

Post code and especially the data using the Insert Code or Insert SAS code buttons in the editor.

Otherwise important information, like which columns the data is in, whether there is anything to make the end of the team name, etc. will be lost because the forum will format your post into paragraphs.

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

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