Reputation: 474
I am having trouble reading in inconsistent comma separated data. Here is a sample of what the data looks like:
JefferyThomas,"200","2,500","12,344",100,"999","865,100",800 GeorgeMontgomery,"50","700",200,"2,500","2,500","8,000","950"
I have never dealth with both numbers within quotes, as well as numbers not in quotes. If it was just one or the other, obviously that is not difficult to read in. But because some numbers are in quotes, and others not, I find myself having trouble reading in all of the data. This is what I have tried so far:
Data test;
INFILE ......"data.csv" dlm="," dsd missover;
length Name $16;
input Name $ Score1 Score2 Score3 Score4 Score5 Score6 Score7;
All this returns is missing values except for the numbers that aren't within quotes.
Upvotes: 1
Views: 64
Reputation: 9109
You need to also tell SAS to read numbers with commas using COMMA INFORMAT.
Data test;
INFILE cards dlm="," dsd missover;
length Name $16;
informat score1-score7 comma16.;
input (_all_)(:);
cards;
JefferyThomas,"200","2,500","12,344",100,"999","865,100",800
GeorgeMontgomery,"50","700",200,"2,500","2,500","8,000","950"
;;;;
run;
proc print;
run;
Upvotes: 4