BookmarkSubscribeRSS Feed
wang_ziyi01
Calcite | Level 5

Hi there

I entered 30 lines but studio only read 10 with data showed.It didn't show the data for another two numerical columns instead it only showed 10 columns of the first row. the others are dash sybols.

Where must dollar signs ($) be placed, so SAS would read the data set correctly?

Can you help me with it? Thx.

8 REPLIES 8
Reeza
Super User

Can you post the code you used?

ballardw
Super User

Show the code you used and log. There are common conditions that will make SAS read lines incorrectly and there may be messages in the log such "went to the next line". Example data will help also.

 

If you are asking about $ on an Input statement it is after the variable to read as character.

 

ChrisBrooks
Ammonite | Level 13

Can you post the code you used - it's not really possible to give you an answer otherwise.

wang_ziyi01
Calcite | Level 5

Yes. Thanks.

data exercise1;

input Team $ Attendance Price;

cards;

Atlanta1399320.06
Boston1491622.54
Charlotte2390117
Chicago1840421.98
Cleveland1696919.63
Dallas1686817.05
Denver1266817.4
Detroit2145424.42
Golden State1502517.04
Houston1584617.56
Indiana1288513.77
LA Clippers1186921.95
LA Lakers1737829.18
Miami1500817.6
Milwaukee1608814.08
Minnesota2616010.92
New Jersey1216013.31
New York1781522.7
Orlando1560620.47
Philadelphia1401719.04
Phoenix1411416.59
Portland1288422.19
Sacramento1701416.96
San Antonio1472216.79
Seattle1224418.11
Utah1261618.41
Washington1156514.55

;

proc print data=exercise1;

run;

Reeza
Super User

Can you please repost that using the insert code at the top of the editor. 

 

It's likely an issue with spaces vs tabs, but the browser is going to mess it up if you don't post it as pure text.

ballardw
Super User

You have at least two problems.

 

First when you use

Input team $ ...

The length of the team will default to 8 characters. So you need more to tell SAS that you need to read at least 12 characters.

Second is that you have spaces in some of the team names.

The input statement you are using is called "list input". By default, unless using file that has a specific delimiter and you tell SAS what the delimiter may be, the space separtes the "words" so Golden would be the first "word" and without additional information SAS reads the "word" as the Attendance. Since "State" is not a number then you get an error, there would be an entry in the log about that, and the value is set to missing.

 

Depending on exactly what your input actually looks like there are different approaches to read the data.

Very old school is fixed column. In the following example the values after the team names are moved enough columns to have spaces and then tell SAS to rean the team name from the first 12 columns before using list input for the other two variables.

data exercise1;
input Team  $ 1-12  Attendance Price;
cards;
Atlanta        13993 20.06 
Boston         14916 22.54 
Charlotte      23901 17 
Chicago        18404 21.98 
Cleveland      16969 19.63 
Dallas         16868 17.05 
Denver         12668 17.4 
Detroit        21454 24.42 
Golden State   15025 17.04 
Houston        15846 17.56 
Indiana        12885 13.77 
LA Clippers    11869 21.95 
LA Lakers      17378 29.18 
Miami          15008 17.6 
Milwaukee      16088 14.08 
Minnesota      26160 10.92 
New Jersey     12160 13.31 
New York       17815 22.7 
Orlando        15606 20.47 
Philadelphia   14017 19.04 
Phoenix        14114 16.59 
Portland       12884 22.19 
Sacramento     17014 16.96 
San Antonio    14722 16.79 
Seattle        12244 18.11 
Utah           12616 18.41 
Washington     11565 14.55 
;
run

Other approaches would be using a delimeter such as a comma between each value tell SAS to use comma as a delimeter.

 

ShiroAmada
Lapis Lazuli | Level 10
data exercise1;
input Team  $ 1-15  Attendance 8. Price 8.;
cards;
Atlanta        13993 20.06 
Boston         14916 22.54 
Charlotte      23901 17 
Chicago        18404 21.98 
Cleveland      16969 19.63 
Dallas         16868 17.05 
Denver         12668 17.4 
Detroit        21454 24.42 
Golden State   15025 17.04 
Houston        15846 17.56 
Indiana        12885 13.77 
LA Clippers    11869 21.95 
LA Lakers      17378 29.18 
Miami          15008 17.6 
Milwaukee      16088 14.08 
Minnesota      26160 10.92 
New Jersey     12160 13.31 
New York       17815 22.7 
Orlando        15606 20.47 
Philadelphia   14017 19.04 
Phoenix        14114 16.59 
Portland       12884 22.19 
Sacramento     17014 16.96 
San Antonio    14722 16.79 
Seattle        12244 18.11 
Utah           12616 18.41 
Washington     11565 14.55
;
run;

proc print;
run;
Kurt_Bremser
Super User

To post SAS code, use the "little running man" icon on top of the post editor. This will preserve code formatting, and display in a "enhanced-editor-like" coloring. For logs or list data, use the {i} icon; preserves formatting, but does no coloring.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 8 replies
  • 1079 views
  • 0 likes
  • 6 in conversation