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

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
;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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.

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

So I copied and pasted what you posted and it looks like your data must have TAB characters in it instead of spaces.

image.png

 

novinosrin
Tourmaline | Level 20
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
kfluegge
Fluorite | Level 6

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;
novinosrin
Tourmaline | Level 20

Not sure what your data is. I pasted a tested one using your sample. Is it not the one you provided?

ballardw
Super User

@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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 1045 views
  • 0 likes
  • 4 in conversation