Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Infile statement

Status
Not open for further replies.

sophie123

Programmer
Nov 2, 2004
10
0
0
US
data test;
Infile
'C:\Documents and Settings\C-sophie\Desktop\Star_200505.txt' DSD missover;
input svc_accs_id 1-10
score 59;
Run;

I have the following code.
When I use the infile statement to create a sas data set It make the data set column a number 8.

How do I make it a 10 long?

Most if not all of the data is 8 long but input file is a fixed length ascii file.
Also when once the file is imported as a SAS dataset I go to the properties of the table and look at the table column properties the format is blank this is causeing problems when I try and join on the table because it view this column as type = float.
 
Sophie123,
What you are doing when you write that input statement is telling SAS system to read an int type from columns 1-10. SAS has two types (up until ver 8) of vars. 1 is an int (float) and the other is a char type.

What I think you should do (I am presuming that the data is all text) is make your vars char types. This way you will get all your data and if you wish to convert them to an int type you can use the input function.
Here is how I would write the statement:
Code:
input svc_accs_id $ 1-10 score $ 59;

Now another way that sas can read the data is by column. If your data is very rigid (stuff always exists in column 1-10 and there is always data in between that and 59) you could use the following statement:
Code:
input svc_accs_id $ score $;
I'm assuming that there always is some data between the two points. If you have other spaces between the points you could insert dummy vars like this.
Code:
input svc_accs_id $ dummy1 $ dummy2 $ score $;

I hope that this has helped you.
klaz


 
Also if the data is a fixed length format, the DSD option is redundant. DSD tells SAS that if there are two delimiters next to each other, then this is a missing variable. By default, two delimiters next to each other denote a variable with the delimiter in it. Also DSD tells SAS that the delimiter is a comma, though this can be overridden with a DELIM= option.
Also, the numeric column having length 8 refers to the number of bytes given to hold the number, not the number of digits in it. 8bytes will allow a very large number to be held (2 to the power 8 theoretically, but it's actually short of that due to a sign bit and some other overhead bits).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top