SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
naks02
Calcite | Level 5

 

I have written a linux shell script for SAS users, when executed on the server it prompts the user for example, userID, appID, Authdomain. Users don't have access to the server to execute the script. I would appreciate assistance on how to write a sas program that users can input mentioned variables in SASStudio and get pushed to linux variables. I don't want the values to be hard coded. My understanding this can be done using macro variables but don't know how.

 

bash script when executed on the server side.

read -r SAS_SERVICES_ENDPOINT
read -r userID
read -r AdGroup

 

Am assuming the shell script will change to this when receiving input from sas program.

export SAS_SERVICES_ENDPOINT=&Sas_end_point
export ADGROUP=&AdGroup
export FID=&userID
export APPID=&AppID

Regards.

 

5 REPLIES 5
yabwon
Onyx | Level 15

Will this script be executed from the SAS Studio level (in the current user SAS Studio sas session )? 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

so how about creating a macro calling X inside:

%macro runBashScript(Sas_end_point,AdGroup);
x "export SAS_SERVICES_ENDPOINT=&Sas_end_point";
x "export ADGROUP=&AdGroup";
/*
...
*/
x "/path/to/the/script/theScript.sh";
%mend;

and for user it would be:

%runBashScript(
https://enpoint.com/
,supergroup
)

to run;

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



naks02
Calcite | Level 5

I thought I had sent this, apologize for the the delay. The macro variables are not being passed to the shell script. Thoughts?

shell script variable set to

export SAS_SERVICES_ENDPOINT=$sas_end_point
export AUTHDOMAIN=$Authdomain
export ADGROUP=$AdGroup
export FID=$Fid
export APPID=$AppID
export PASSWORD=$Password
Password=$(echo -n "Password" | base64);


log of sas program, macro variables are set as below

* Set values;
%macro authUpdate(sas_end_point,AdGroup,Fid,Authdomain,AppID,Password);
x "export SAS_SERVICES_ENDPOINT=&sas_end_point";
x "export ADGROUP=&AdGroup";
x "export FID=&FID";
x "export AUTHDOMAIN=&Authdomain";
x "export USERID=&UserID";
x "export PASSWORD=&Password";
/* ... */
x "/cloud/svv001/scenarios/a_sasad/amos/set-pass-viya_Copy2.sh";
%mend;

/* User info to update authdomain */
%authUpdate(https://sasviya-dev.apps.test.net/ ,AmosNewOAuth , SASVIYA_100421-88790-PROD ,b28111 ,88821-A-SASVIYA, Password);

 

Shell script  variables after sas program is ran. Macro variables are not passed to the shell script
+ echo
>
> + export SAS_SERVICES_ENDPOINT=
> + SAS_SERVICES_ENDPOINT=
> + export AUTHDOMAIN=
> + AUTHDOMAIN=
> + export ADGROUP=
> + ADGROUP=
> + export FID=
> + FID=
> + export APPID=
> + APPID=
> + genToken
> ++ curl -s -k /SASLogon/oauth/token -H 'Content-Type: application/x-www-form-urlencoded' -d grant_type=client_credentials -u
client-E4AA2EA2841DC958350A18D59DDCF030:b24830bc88a9ce1fd28bffe3d31ba1d0ba5398701b31ef8730dd70ac5f9de027
> ++ grep -oP '{"access_token":"\K.*?(?=",")'
> + export OAUTH_TOKEN=
> + OAUTH_TOKEN=

naks02
Calcite | Level 5

Giving it a try, will update.

 

Thank you!

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1987 views
  • 1 like
  • 2 in conversation