Hello, I need help. I want to download data from the next url : eurocontrol
How can I do it? Thank you
That's because they use a dot for decimals in the first file, and a comma in the second. A typical violation of the structural "agreement".
If that change was not documented, I would alert the source to that. If it is documented, you will have to adapt the code so that it can deal with it:
data want;
infile in dlm='09'x dsd;
input
code :$2.
date1 :yymmdd10.
date2 :yymmdd10.
number1
_number2 :$10.
code2 :$3.
name :$40.
;
if indexc(_number2,',')
then number2 = input(_number2,commax10.);
else number2 = input(_number2,10.);
drop _number2;
run;
Try this:
filename in url "https://www.eurocontrol.int/sites/default/files/2019-07/ur-2019-07-update.txt";
data want;
infile in dlm='09'x dsd;
input
code :$2.
date1 :yymmdd10.
date2 :yymmdd10.
number1
number2
code2 :$3.
name :$40.
;
run;
Note that this will only work if you have the proper certificate chain on your SAS server so that https works.
Thank you very much. Your code is really work. But when I try to read the first or second month, I got an error.
https://www.eurocontrol.int/sites/default/files/2019-06/ur-2019-01.txt
https://www.eurocontrol.int/sites/default/files/2019-06/ur-2019-02.txt
As I see, the problem is with number2 in your example.
As I understand, it can be two different delimiters, sometimes tab delimiter, and sometimes blank delimiter.
That's because they use a dot for decimals in the first file, and a comma in the second. A typical violation of the structural "agreement".
If that change was not documented, I would alert the source to that. If it is documented, you will have to adapt the code so that it can deal with it:
data want;
infile in dlm='09'x dsd;
input
code :$2.
date1 :yymmdd10.
date2 :yymmdd10.
number1
_number2 :$10.
code2 :$3.
name :$40.
;
if indexc(_number2,',')
then number2 = input(_number2,commax10.);
else number2 = input(_number2,10.);
drop _number2;
run;
You are right. But still I have a problem, when I try to read month 1 and 2.
You can see, that code2 variable in some cases inside name variable.
I tried multiple delimiters, like
dlm=' ' || '09'x;
dlm=dlm,
but it doesn't work me
https://www.eurocontrol.int/sites/default/files/2019-06/ur-2019-01.txt
https://www.eurocontrol.int/sites/default/files/2019-06/ur-2019-02.txt
That's because the file is not properly structured. In line 6 of 2019-01, there's a blank separating number2 and code2 instead of a tab. The people there clearly need to get their act together. If everything else is built as sloppily as this, I would not trust this data at all. Who knows what other errors are hidden in there.
Note that we can't use blanks as additional delimiters, as name often contains blanks.
PS 2019-02 looks much better, so it may be that the problems were corrected from there on.
Thank you very much!
filename in url "https://www.eurocontrol.int/sites/default/files/2019-07/ur-2019-07-update.txt"; proc import datafile=in out=want dbms=tab replace; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.