Hello everyone,
I designed my data in Excel to run in SAS; however, SAS does not read the data. The output data shows some dots. Screenshot is attached.
I have my different fertilizers treatments (frt) in the first column, the second column is plant height (ph), and the third row is the week that I have, which will be for repeated measures. Since fertilizers are non-numeric values, I put the'' $'' sign next to ''frt''. Does anyone know what causes this issue and how to correct it?
If you have inserted actual TAB characters into your in-line data then you can use the EXPANDTABS option of the INFILE statement to have SAS replace them with the proper number of spaces to move to the next tab stop. Also add the TRUNCOVER option incase any of the lines have fewer values on them than the INPUT statement wants. If you need to represent a missing value in the data use a single period (for either numeric or character variables).
data Waterford;
infile datalines expandtabs truncover ;
input frt$ ph Week;
datalines;
XXX 1 2
YYY 2 3
ZZZ . 4
. 5 6
;
Note that most of the SAS editors (and most full functioning text editors) have an option to replace tabs with spaces when typing. So you can use the TAB key like you would on an actual typewrite, to move to the next tab stop, and the editor will insert the right number of spaces to get there.
I suspect you have tabs instead of spaces between your data values?
Did not work is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.
The suggestion was an OPTION on an INFILE statement that reads an external file. If you don't have the INFILE point to the correct file, or any file, then it will not work.
Please include the LOG with the whole submitted code as text as shown above. We can't make copy/edit/paste corrections to code that appears in pictures.
there is no errors in the log! It did not work out, which means that when I ONLY run the datelines, I still see the dots. I also did put '' infile data lines dlm='09'x;'' after ''data'' statement on the top. I was not sure I put the infile statement in the correct place. This is the log:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data Waterford;
70 infile datalines dlm='09'x;
71 input frt$ ph Week;
72 datalines;
NOTE: Invalid data for ph in line 74 1-3.
NOTE: Invalid data for Week in line 74 5-80.
If you have inserted actual TAB characters into your in-line data then you can use the EXPANDTABS option of the INFILE statement to have SAS replace them with the proper number of spaces to move to the next tab stop. Also add the TRUNCOVER option incase any of the lines have fewer values on them than the INPUT statement wants. If you need to represent a missing value in the data use a single period (for either numeric or character variables).
data Waterford;
infile datalines expandtabs truncover ;
input frt$ ph Week;
datalines;
XXX 1 2
YYY 2 3
ZZZ . 4
. 5 6
;
Note that most of the SAS editors (and most full functioning text editors) have an option to replace tabs with spaces when typing. So you can use the TAB key like you would on an actual typewrite, to move to the next tab stop, and the editor will insert the right number of spaces to get there.
Excel does insert tabs between cells when you copy and paste the values as text.
If you paste that into Display Manager Enhanced editor then the tabs remain. But when you submit the program from display manager then the tabs in the program editor are converted to spaces automatically.
So I suspect you are using SAS/Studio or some other front end tool for submitting your code where that does not happen. If you change your preferences in SAS/Studio to replace the tabs then they are NOT pasted into the program editor.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.