I am importing data from a website. It uses a semicolon as a delimiter for three fields. Unfortunately, for some reason, a fourth, trailing delimiter exists (I can't change the webpage). Can I tell SAS to ignore the last ";" Currently, it creates a fourth field called VAR4. Its not fatal, but its cloying. Thanks
A header and first line of data:
DATE;CANADAI;CANADAR; 03JAN1992; 0.871612; 0.871612;
filename infile temp;
proc http
url="https://...website.../&insheet..txt"
method="GET"
out=infile;
run;
/* Tell SAS to allow "nonstandard" names */
options validvarname=any;
proc import datafile=infile
out=root.&insheet
dbms=dlm
replace;
delimiter=';';
getnames=yes;
run;
With just three columns, there is absolutely no need for IMPORT. You already have the data step code in the log, take it from there and remove VAR4.
With just three columns, there is absolutely no need for IMPORT. You already have the data step code in the log, take it from there and remove VAR4.
As @Kurt_Bremser said, proc import is best avoided.
If you really want to keep proc import you can drop the variable
out=ROOT.&insheet(drop=VAR4)
Thank you Kurt and Chris. Unfortunately, I have to keep the Proc Import because &insheet sometimes resolves to a long characters string. So, I just drop it at that 2nd step.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.