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

I am trying to adjust the order of data but I keep on receiving an error. "Score" is a numeric value, and it will not read it as one. the only way to have SAS read it is as a categorical value 

 

DATA WORK.;
INFILE DATALINES;
INPUT @38 Score 40.
@1 Hospital $ 24.;
* Ruler 1 1 2 2 3 3 4 4 5 5 6
1---5----0----5----0----5----0----5----0----5----0----5----0;
DATALINES;
Md Anderson Houston TX 100.0
Memorial Sloan-Kettering New York NY 97.4
Mayo CLinic Rochester MN 91.8
Dana-Farber Boston MA 84.4
;

 and then i receive this error

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 DATAWORK.;
74 INFILEDATALINES;
75 INPUT @38 Score 40.
___
499
ERROR 499-185: Width specified for informat F is invalid.
 
76 @1 Hospital $ 24.;
77 * Ruler 1 1 2 2 3 3 4 4 5 5 6
78 1---5----0----5----0----5----0----5----0----5----0----5----0;
79 DATALINES;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You need to be aware the the main message windows will reformat text. Typically that means white space is reduced.

So what we see may not be as you intend or expect. To prevent this reformatting paste text into a code box opened on the forum using the </> icon.

 

When I examine this bit of your post:

DATA WORK.Illus;
INFILE DATALINES;
INPUT @38 Score 40.
@1 Hospital $ 24.;
* Ruler 1 1 2 2 3 3 4 4 5 5 6
1---5----0----5----0----5----0----5----0----5----0----5----0;
DATALINES;
Md Anderson Houston TX 100.0
Memorial Sloan-Kettering New York NY 97.4
Mayo CLinic Rochester MN 91.8
Dana-Farber Boston MA 84.4

 

The only line that Score starts on or after column 38 is the second.

 

The F format, which is actually what you use when you specify Score 40. (the F is implied when only a number is encountered) , has a limit or maximum width of 32, which is cause of the Error message.

View solution in original post

2 REPLIES 2
CurtisMackWSIPP
Lapis Lazuli | Level 10

SAS has numeric and string variables, that is it.  By categorical I assume you mean a string.  If that is the case just put a $ before the 40 so that is a string.  Without the $ SAS thinks you want a numeric, and the maximum length for a numeric is 8.

 

That said, this code will not work because you are using fixed with inputs and your datalines are not fixed width.

 

Since these datalines also do not have a delimiter that is not also in the data, the only way to read it is to read the entire line and then parse the values out using the scan with negative indexes.  Let me know if this will be necessary and we can show you how. 

 

This code will work because I added the $ and standardized the datalines.

 

DATA WORK.Illus;
  INFILE DATALINES;
  INPUT @39 Score $40.
  @1 Hospital $ 24.;
DATALINES;
Md Anderson              Houston   TX 100.0
Memorial Sloan-Kettering New York  NY 97.4
Mayo CLinic              Rochester MN 91.8
Dana-Farber              Boston    MA 84.4
;
run;
ballardw
Super User

You need to be aware the the main message windows will reformat text. Typically that means white space is reduced.

So what we see may not be as you intend or expect. To prevent this reformatting paste text into a code box opened on the forum using the </> icon.

 

When I examine this bit of your post:

DATA WORK.Illus;
INFILE DATALINES;
INPUT @38 Score 40.
@1 Hospital $ 24.;
* Ruler 1 1 2 2 3 3 4 4 5 5 6
1---5----0----5----0----5----0----5----0----5----0----5----0;
DATALINES;
Md Anderson Houston TX 100.0
Memorial Sloan-Kettering New York NY 97.4
Mayo CLinic Rochester MN 91.8
Dana-Farber Boston MA 84.4

 

The only line that Score starts on or after column 38 is the second.

 

The F format, which is actually what you use when you specify Score 40. (the F is implied when only a number is encountered) , has a limit or maximum width of 32, which is cause of the Error message.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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