BookmarkSubscribeRSS Feed
britney09
Calcite | Level 5

Im trying to read in a text file, that is stored in list format with multiple observations per line in the order of :ID, score , dose age weight 

 

the text file is attached 

 

8 REPLIES 8
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Please post what you have tried and post you data in the form of a SAS datastep using either the cards or datalines;

When I open your attachment I only get a picture of the information.

 

use a datastep and an infile statement based on the information you have provided.

Peter_C
Rhodochrosite | Level 12
the infile option FLOWOVER (which is the default) is designed to support your data
r_behata
Barite | Level 11
/*This code is not tested, but double trailing@@ should do the trick.*/



filename dehyd '<path>/dehydration_f18.txt'; data temp; infile dehyd lrecl=80 flowover firstobs=1; input ID $ score dose age weight @@; run;
britney09
Calcite | Level 5

Thank you! 

novinosrin
Tourmaline | Level 20

 

data want;
infile 'C:\Users\nsriniv2\Downloads\dehydration_f18.txt';
input ID $ score dose age weight @@;
run;

proc print nobs;run;

 

 

SAS Output

The SAS System

ID score dose age weight
1 76 0.0 4 28
2 65 1.5 5 35
3 75 2.5 8 55
4 61 1.0 9 76
5 75 0.5 5 31
6 82 2.0 5 25
7 70 1.0 6 35
8 91 2.5 6 47
9 49 0.0 9 57
10 72 3.0 8 51
11 65 2.0 7 51
12 100 2.5 7 46
13 75 1.5 4 33
14 58 3.0 8 57
15 58 1.5 6 41
16 56 0.0 8 55
17 81 1.0 7 55
18 55 2.0 10 76
19 44 0.5 9 66
20 62 1.0 6 43
21 61 1.0 6 42
22 74 2.5 7 51
23 76 1.5 5 29
24 81 2.5 11 64
25 68 3.0 9 61
26 70 2.5 10 72
27 93 1.5 4 25
28 84 2.0 3 26
29 71 0.0 9 56
30 59 2.5 8 57
31 88 1.0 3 22
32 68 0.5 5 38
33 61 0.5 6 44
34 91 3.0 5 45
35 79 1.5 8 53
36 91 2.0 4 29

 

 

 

 

 

 

 

 

novinosrin
Tourmaline | Level 20
data want;
infile 'C:\Users\nsriniv2\Downloads\dehydration_f18.txt';
do _n_=1 to 3;
input ID $ score dose age weight @;
output;
end;
run;
britney09
Calcite | Level 5

Thank you! it worked!

s_manoj
Quartz | Level 8

HI,

 

data want;
infile "path.txt";
input id v1 v2 v3 v4 @@;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1533 views
  • 1 like
  • 6 in conversation