SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Balli
Obsidian | Level 7

 

Hello Team, 

I am writing this python script to upload the files to SFTP and I want to dynamically pass the file name as a macro variable. Unfortunately we can not use the submit block inside a macro function. Can someone please help me with a solution ? or an alternative way to SFTP the files?

 

PROC Python.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
HarrySnart
SAS Employee

Hi @Balli 

 

You can't call macro variables in the script that way, instead the macro variable needs to be passed using the SAS variable which is created as part of the PROC PYTHON session.

 

You should be able to use SAS.symget('') where you've highlighted the issue in your code in yellow.

 

see example from documentation below:

%let myvar = Jane Doe;

proc python;
submit;
x = SAS.symget('myvar')
print('macro variable myvar = ' + x)

py_var = 'Inside python'
SAS.symput('macrovar', py_var)
endsubmit;
run;

%put &=macrovar;
%put &=myvar;

Thanks

Harry

View solution in original post

2 REPLIES 2
HarrySnart
SAS Employee

Hi @Balli 

 

You can't call macro variables in the script that way, instead the macro variable needs to be passed using the SAS variable which is created as part of the PROC PYTHON session.

 

You should be able to use SAS.symget('') where you've highlighted the issue in your code in yellow.

 

see example from documentation below:

%let myvar = Jane Doe;

proc python;
submit;
x = SAS.symget('myvar')
print('macro variable myvar = ' + x)

py_var = 'Inside python'
SAS.symput('macrovar', py_var)
endsubmit;
run;

%put &=macrovar;
%put &=myvar;

Thanks

Harry

Balli
Obsidian | Level 7

Thanks @HarrySnart , works like a charm 🙂

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
  • 2 replies
  • 2020 views
  • 2 likes
  • 2 in conversation