Error I am receiving.. all of my data is listed in one column instead of three. And Im only getting 10 observations there should be at least 30-40.
Code I used
data hwbiostat6;
infile "/folders/myfolders/hwbiostat6/ch12q06.txt" dlm='09'x firstobs=2;
input SEX $ Y X;
if sex="M" then Zsex=1;
else Zsex=0;
Xsex= X*Zsex;
datalines;
M 17.1 0.301
M 14.3 0.301
M 21.6 0.301
M 24.5 0.602
M 20.6 0.602
M 23.8 0.602
M 27.7 0.903
M 31 0.903
M 29.4 0.903
M 30.1 1.204
M 28.6 1.204
M 34.2 1.204
M 37.3 1.204
M 33.3 1.505
M 31.8 1.505
M 40.2 1.505
F 18.5 0.301
F 22.1 0.301
F 15.3 0.301
F 23.6 0.602
F 26.9 0.602
F 20.2 0.602
F 24.3 0.903
F 27.1 0.903
F 30.1 0.903
F 28.1 0.903
F 30.3 1.204
F 33 1.204
F 35.8 1.204
F 32.6 1.505
F 36.1 1.505
F 30.5 1.505
;
run;
Please attach ch12q06.txt.
Also, why are you using infile statements and datalines ry?
Please attach ch12q06.txt.
Also, why are you using infile statements and datalines ry?
Im using SAS university. I think I may have figured it out using dsd instead of dlm. Let me know what you think.
Yes, I think you can use the dsd option instead of dlm since it is a csv file.
It worked, thank you!
It is probably time for you to learn that opening files that are CSV with a spreadsheet can change things.
Your original file was comma separated and you wrote a data step to read a TAB delimited file, almost certainly because you copied cells from a spreadsheet.
Dlm=',' with the file likely fixes lots of issues.
We can tell such things as the file was comma delimited by reading the log:
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 4 'M',21.6,0.301 14
The bit between the "4" and the "14" is the actual content of the file read.
You want to copy from the log and paste copied text into a text box opened on the forum with the </> icon to preserver the text formatting that SAS has in the log. I bet that if you look in your log that the 'M' for that line started on column 4 of the file with the first quote under the - character before the first + sign. The + occurs as position multiples of 5 characters, the 1, 2, 3 etc indicate column 10, 20, and 30 .
The main message windows on this forum reformat text, generally removing white space, so fixed column information from the line ruler above gets corrupted.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.