I am new to SAS, and i have a problem I am trying to resolve. I have parts of it done but i keep getting errors and i thought why not post it on here, most i can do is get laughed at because i dont know SAS.
Problem.
Write a SAS® program to access the Microsoft® Excel® spreadsheet and select these four specific data items:
Create a comma-delimited raw data file to store information that includes gender, earnings categories, and number of individuals in each category for only the data indicated above.
What i have done so far is attached in a comma delimited file as far as my excel sheet, I am not getting how to list these out and retrieve the data in a table. So far the code below is the best i have come up with for this resolution. Any help would be grand and appreciated.
Thanks!
data Auglaize;
infile ' /home/ktylu10/sasuser.v94/Week 2 Individual Auglaize County.csv’ dlm=',' firstobs=2;
input ? : $char# ? : $char# ? : $char# ? : $char#;
run;
proc print data=Auglaize;
run;
When you receive ERRORs, it is best to post the log from the offending step(s).
If you're trying to read in a csv file, in which the first row are variable/column names, I'd suggest learning about proc import. Then you can go on to the subsequent tasks.
data Auglaize;
infile '/home/ktylu10/sasuser.v94/Week 2 Individual Auglaize County Jason.csv’ dlm=',' firstobs=2;
Input Gender :$6. Income :$20. Fulltime 8:$15 comma8.0;
run;
proc print data=Auglaize;
run;
The log doesn't match the code posted?
Please make sure the exact code and log are included.
The closing quote at the end of your infile name is not a standard single quote. Try this instead:
data Auglaize;
infile '/home/ktylu10/sasuser.v94/Week 2 Individual Auglaize County Jason.csv' dlm=',' firstobs=2;
Input Gender :$6. Income :$20. Fulltime 8:$15 comma8.0;
run;
I uploaded your .csv (which is in DOS format with CRLFs, something you should correct if you try to read on UNIX) to my UNIX server using text mode (converts the CRLF to LF) and ran this:
data auglaize;
infile '$HOME/sascommunity/auglaize_county_2.csv' dlm=',' firstobs=2 ;
input gender :$6. income :$20. fulltime other;
run;
proc print data=auglaize noobs;
run;
The result:
gender income fulltime othe Male 55000 to 64999 1041 203 Male 65000-74999 712 199 Male 75000-99999 1168 159 Male 100000 or more 39 112 Female 55000 to 64999 572 241 Female 65000-74999 230 104 Female 75000-99999 213 91 Female 100000 or more 125 39
Note that I replaced the stupid blanks in the filename with underlines. Is much easier to handle during file operations on the OS level.
1) I think the Forum treats that a xls as when I do a save target as from the browser the file name looks ends in XLS.
I would recommend using the import wizard the first time to bring the data into sas. Look in the File menu for Import data. That will generate a program to read the data that will appear in the Log. You could copy the text from the log to the editor and edit as needed.
It will look something like:
data WORK.AUGL ; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ infile '<path>\Auglaize County 2.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ; informat Gender $7. ; informat Income $14. ; informat Fulltime best32. ; informat Other best32. ; format Gender $7. ; format Income $14. ; format Fulltime best12. ; format Other best12. ; input Gender $ Income $ Fulltime Other ; if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ run;
You can save the program to run later as well.
.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.