I have written below code
proc import file = "/home/u62799951/sasuser.v94/My_Folder/Data.csv" out = MyData dbms = csv replace;
run;
data MyData;
length COUNTRY $5;
stopover;
input COUNTRY $;
run;
In Data.csv
, there is one column called COUNTRY
which holds names of different countries. My intention is if Country name has more than 5 letters than there should be an error. And I tried to use STOPOVER
in that context.
However above code does not show any error despite there are country name like Malaysia
.
Could you please help to get the right code?
STOPOVER will stop the data step when the line does not have enough characters to satisfy the input. The opposite of what you seem to want.
If you want to test if something has too many characters you will need to write that logic yourself.
data want;
infile .... truncover ;
length dummy $20 country $5 ;
input dummy ;
if length(dummy) <= 5 then country=dummy;
else do;
put 'ERROR: ' dummy 'is too long a value for country.';
stop;
end;
drop dummy;
run;