Up to now, I have been using a proc s3 procedure to download file.
But now, I would prefer to use a aws s3 command to download a csv file by specifying the profile I want to use.
How do we do that ?
Based on documentation and starting with SAS 9.4M5 you can specify the profile with both Proc S3 and the Filename S3 access method. There shouldn't be a need for explicitly calling the aws cli.
Optional Arguments
The aws cli command for downloading a file will look similar to below.
aws s3 cp s3://your-bucket-name/your-file.csv /path/to/destination/ --profile your_profile_name
You need of course the aws cli installed from the environment where SAS executes.
To use a filename pipe with reading the .csv directly via a SAS data step I assume you would need to write directly to standard out. Copilot returned syntax as below for such a scenario.
aws s3 cp s3://your-bucket-name/your-file.csv - --profile your_profile_name --output text
In this command:
-
after the S3 path tells the AWS CLI to write the output to stdout.--output text
specifies the format of the output. You can also use --output json
if you prefer JSON format.It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.