SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

Do you know please how to import the file from web. I'm using the code like :

 

 

data scores;
   infile "http://XXXX/Liste.txt" truncover;
   format name $8.;
   informat name $8.;
   input name ;
 run;

But it doesn't work.

 

Thank you very much for your help !

8 REPLIES 8
SASdevAnneMarie
Barite | Level 11

Thank you !
My problem is that this file doesn't existe until clicking on http://XXXXXX. In web, there is the request (the client's request -> server) and the response (server -> client's browser). The response from http://XXXXXX is a file stream type txt (generated with php).
I'm wondering if there is possible to import this kind of file. 

ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.

SASdevAnneMarie
Barite | Level 11
Thank you !
I have an error that there is no file. My problem is that this file doesn't existe until clicking on http://XXXXXX. In web, there is the request (the client's request -> server) and the response (server -> client's browser). The response from http://XXXXXX is a file stream type txt (generated with php).
I'm wondering if there is possible to import this kind of file.
ballardw
Super User

Perhaps Proc HTTP can help.

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=proc&docsetTarget=n0t7v16...

 

You can provide instructions like "GET" to request data but I don't use this and there are likely to be a number of additional pieces of information that you may need to provide to get the correct connection.

Tom
Super User Tom
Super User

You need to use the URL filename engine. Otherwise is just going to look for a file on the local computer with that name.

infile "http://XXXX/Liste.txt" url truncover;
SASdevAnneMarie
Barite | Level 11
Thank you Tom ! The file is generated by php only if I request it with http://XXXXXX, so it's "instantly generated txt file". I don't know If I can use the proc http with that.
Tom
Super User Tom
Super User

@SASdevAnneMarie wrote:
Thank you Tom ! The file is generated by php only if I request it with http://XXXXXX, so it's "instantly generated txt file". I don't know If I can use the proc http with that.

It is not 1992 anymore.  Most of the url's on the web are not pointing at actual files.  So try it and see.  

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2136 views
  • 4 likes
  • 4 in conversation