Copy a file from a web server to your local computer.
The %net_copy macro will download a file over the internet to your local computer. The file can be a text file (such as
a SAS program, e.g. test.sas) or a binary file (such as a SAS data file, e.g. test.sas7bdat).
%net_copy( url_file , data_loc [ , filename , bin=0/1 ) ]
- The url_file is the web address of the file you want to download, including the name of the file. This parameter is required.
- The data_loc is the name of a folder on your local machine where you would like the file to be downloaded. This parameter is required.
- The filename is the name you would like for the file on your local machine. This parameter is optional, and the default is that the file will have the same name as it did on the web server.
- The bin option allows you to specify whether the file should be downloaded in binary mode (i.e. bin=1) or in text mode (i.e. bin=0). If you are downloading a text file then you would want to download the file in text mode, and if you are downloading a data file (e.g. a .sas7bdat file) then you would want to download the file in binary mode. The default is to download files in text mode.
To download test.sas from https://stats.idre.ucla.edu/stat/sas/macros and store it in c:myfiles you can type
%net_copy( https://stats.idre.ucla.edu/stat/sas/macros/test.sas , c:myfiles )
To do the same as above, but rename the file to be myfile.sas, you can type
%net_copy( https://stats.idre.ucla.edu/stat/sas/macros/test.sas , c:myfiles , myfile.sas)
To download hsb2.sas7bdat from https://stats.idre.ucla.edu/stat/sas/macros and store it in c:myfiles you can type the following. Note that you need the bin=1 parameter to specify a binary transfer.
%net_copy( https://stats.idre.ucla.edu/stat/sas/macros/hsb2.sas7bdat , c:myfiles , bin=1)
Also see the help for %net_get.