Good Morning! How are you?
I need to import a database in TXT format, but it is in the cloud and not on my machine.
How can I import this database into a specific LIBNAME, in an automated way at a pre-defined time?
Is there any code for this or do you have a tool in SAS that already does this?
Thanks for your help! :)
How do you access the TXT file now? Is there a URL you can use that will return the text from the file?
If so then use the URL filename engine.
So here is an example of a data step that reads from a CSV file with 4 variables.
data want;
infile 'http://servername/location' url dsd truncover firstobs=2;
input var1 var2 var3 :$20 var4 :date. ;
format var4 date9.;
run;
What type of "cloud" access is this?
What operating system are you using?
Are you sure that the cloud file will be available to you "at a defined time"?
If the file will show in your local file management program, such as Windows Explorer as an example, then the path and name used there should work in SAS.
I have many files on a One Drive server for example. Once I have a path to the file I need then a SAS Filename statement will associate the file and can be read (or create a file if needed for output).
So a basic data step to read a TXT file should work just fine once you get the proper path syntax.
I suggest using a scheduling program to start SAS and execute the read.
Note: "Import" when used to indicate Proc Import is a poor choice for repeated reads of different files. The differences between files can lead to variables of the same name having different lengths and data types as the procedure makes guesses based on the actual content of the file "imported". It is much better and will avoid many headaches to have a proper description of the source text file and read it with a data step so things stay consistent.
Thank you so much for your answer! It sure helped me a lot!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.