02-13-2017 06:19 PM
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.
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.
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;
02-13-2017 06:27 PM
02-13-2017 06:37 PM
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.
02-13-2017 09:03 PM
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;
02-14-2017 01:52 AM
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;
02-14-2017 02:05 AM
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;
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.
02-13-2017 06:46 PM
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.