10-15-2015 03:55 PM
I'm trying to the read the following data from a text file into a data set and proc print it.
East Caribbean,799,1514,1335 East Caribbean,1068,2319,1864 East Caribbean,899,999,967 East Caribbean,1240,899,769 East Caribbean,1100,1769,1044 West Caribbean,1018,1065,907 West Caribbean,999,1118,959 West Caribbean,865,815,499 West Caribbean,799,755,529 West Caribbean,832,999,782 South Caribbean,1293,1101,918 South Caribbean,1763,1999,1023 South Caribbean,939,968,895 South Caribbean,770,778,708 South Caribbean,861,1751,954
The code I've written is
infile '/home/lam13h/Data/Cruises2.txt/' dlm=',';
length Itinerary $ 15;
input Itinerary $ &
proc print data=cruises2;
However it isn't reading the data correctly and keeps including commas with the first data column and not including the data in the last 3 columns. I've tried everything I can think of and can't get this to work. Please help
10-15-2015 04:47 PM
The problem is this combination:
The & tells SAS to keep reading until it finds two consecutive delimiters. In this case, that would be two consecutive commas. Just remove the & and that should work for the limited amount of data that you illustrated. If there are other issues, other measures might need to be taken (including the possibility that was already mentioned about switching to PROC IMPORT).