Download a package of files from a web server to your local computer
The %net_get macro will download a package over the internet and install it on your local computer. A
package is simply a list of files available at a web site, and would typically be composed of a SAS macro (e.g.
test.sas), a help file for the macro
(e.g. test.hlp), and possibly one or more supplemental files (e.g. hsb2.sas7bdat). Once you have used %net_get to download
a macro, you can then immediately use that macro. Also, if the macro contains a help file, you can get help on using the macro using the %local_help macro, for example %local_help( test ) .
%net_get( package_name [ url , data_loc , replace=yes ) ]
- The package_name is the name of the package that you want to download, and this parameter is required.
- The url is the location that contains the package that you want to download, and can be optional. The url will default to the most recently used url with any of the %net commands for the current SAS session, so you can omit the url to default to the most recently used url.
- The data_loc is the name of a folder on your local machine where you would like any supplemental data files to be downloaded, and this parameter is optional. If you omit this parameter, the supplemental data files, if any, will not be downloaded. If you include this parameter, the supplemental data files will be downloaded to the location you specify.
- The replace=yes option can be used when a package has already been downloaded and you wish to download and overwrite the existing package. By default, if a package has already been downloaded, it will not overwrite the contents of the package unless you specify the replace=yes option.
To download test from https://stats.idre.ucla.edu/stat/sas/macros you can type
%net_get( test , https://stats.idre.ucla.edu/stat/sas/macros )
To download srs from https://stats.idre.ucla.edu/stat/sas/macros , after having issued to above command and defaulting to the same url, you can type
%net_get( srs )
To download srs from https://stats.idre.ucla.edu/stat/sas/macros again and replace the existing version, you can type
%net_get( srs, replace=yes )
To download test from https://stats.idre.ucla.edu/stat/sas/macros and to include the supplemental data files to c:myfiles, you can type
%net_get( test, , c:myfiles )
or if you want to explicitly name the url you can type
%net_get( test , https://stats.idre.ucla.edu/stat/sas/macros , c:myfiles )