BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AlexeyS
Pyrite | Level 9

Hello, I need help. I want to download data from the next url :  eurocontrol

 

How can I do it? Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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;

View solution in original post

8 REPLIES 8
andreas_lds
Jade | Level 19
Contact the site, they will have set up a service you can use maybe by using proc soap or proc http, but that depends on what they offer.
Kurt_Bremser
Super User

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.

AlexeyS
Pyrite | Level 9

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.

Kurt_Bremser
Super User

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;
AlexeyS
Pyrite | Level 9

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

Kurt_Bremser
Super User

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.

AlexeyS
Pyrite | Level 9

Thank you very much!

Ksharp
Super User
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 694 views
  • 0 likes
  • 4 in conversation