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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1012 views
  • 0 likes
  • 3 in conversation