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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1495 views
  • 4 likes
  • 4 in conversation