I am attempting to read raw data into SAS. I use the code below. It does not read correctly. I would like to find my error(s).
data days;
infile datalines truncover;
input x1 1-2 x2 3-10 x3 11 x4 12-13;
datalines;
9 67.267 0 0
10 109.381 0 0
11 69.690 0 0
12 47.714 0 0
13 76.034 0 0
14 57.073 0 0
15 62.214 0 0
16 55.310 0 0
17 70.957 0 0
18 40.667 1 1
19 58.611 1 2
20 55.889 1 3
21 63.517 1 4
22 60.105 1 5
23 57.800 1 6
24 67.444 1 7
25 71.500 1 8
26 35.450 1 9
27 42.143 1 10
28 53.250 1 11
;
@kfluegge wrote:
I changed the infile statement to that listed below. The output is a blank dataset. I do not think this resolves my problem.
infile datalines dlm=t dsd truncover;
t is not a tab character. Try dlm='09'x
The '09'x means to use the HEX value as an ASCII character and corresponds to the tab character.
So I copied and pasted what you posted and it looks like your data must have TAB characters in it instead of spaces.
data days;
infile datalines truncover ;
input x1 1-2 x2 3-10 x3 12-13 x4;
datalines;
9 67.267 0 0
10 109.381 0 0
11 69.690 0 0
12 47.714 0 0
13 76.034 0 0
14 57.073 0 0
15 62.214 0 0
16 55.310 0 0
17 70.957 0 0
18 40.667 1 1
19 58.611 1 2
20 55.889 1 3
21 63.517 1 4
22 60.105 1 5
23 57.800 1 6
24 67.444 1 7
25 71.500 1 8
26 35.450 1 9
27 42.143 1 10
28 53.250 1 11
;
SAS Output
| The SAS System |
| x1 | x2 | x3 | x4 |
|---|---|---|---|
| 9 | 67.267 | 0 | 0 |
| 10 | 109.380 | 0 | 0 |
| 11 | 69.690 | 0 | 0 |
| 12 | 47.714 | 0 | 0 |
| 13 | 76.034 | 0 | 0 |
| 14 | 57.073 | 0 | 0 |
| 15 | 62.214 | 0 | 0 |
| 16 | 55.310 | 0 | 0 |
| 17 | 70.957 | 0 | 0 |
| 18 | 40.667 | 1 | 1 |
| 19 | 58.611 | 1 | 2 |
| 20 | 55.889 | 1 | 3 |
| 21 | 63.517 | 1 | 4 |
| 22 | 60.105 | 1 | 5 |
| 23 | 57.800 | 1 | 6 |
| 24 | 67.444 | 1 | 7 |
| 25 | 71.500 | 1 | 8 |
| 26 | 35.450 | 1 | 9 |
| 27 | 42.143 | 1 | 10 |
| 28 | 53.250 | 1 | 11 |
I changed the infile statement to that listed below. The output is a blank dataset. I do not think this resolves my problem.
infile datalines dlm=t dsd truncover;
Not sure what your data is. I pasted a tested one using your sample. Is it not the one you provided?
@kfluegge wrote:
I changed the infile statement to that listed below. The output is a blank dataset. I do not think this resolves my problem.
infile datalines dlm=t dsd truncover;
t is not a tab character. Try dlm='09'x
The '09'x means to use the HEX value as an ASCII character and corresponds to the tab character.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.