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
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.
/*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;
Thank you!
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 |
data want;
infile 'C:\Users\nsriniv2\Downloads\dehydration_f18.txt';
do _n_=1 to 3;
input ID $ score dose age weight @;
output;
end;
run;
Thank you! it worked!
HI,
data want;
infile "path.txt";
input id v1 v2 v3 v4 @@;
run;
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.