BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
CadburyAnimal
Calcite | Level 5

Hi,

Running program to set a location (output) up as macro variable then proc export to that location / macro variable.

Unfortunately, SAS gives the below errors.  Any ideas appreciated. P.S. I'm using SAS Studio.

 

CadburyAnimal_0-1652734953831.png

CadburyAnimal_1-1652735005905.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Ok, you didn't follow my advice to remove the double-quotes at the start and end of %let outpath=

 

Now, let me explain how macro variables work. When you run the code, the macro variable itself is replaced by its value, and the result must be legal valid working SAS code. You do not have legal valid working SAS code here.

 

Your line of code

 

outfile="&outpath"

 

after replacement, this is your code

 

outfile=""S:/workshop/epg1v2/output""

 

Can you see why this isn't valid code without macro variables? What would you have to do to make it valid code, without macro variables?

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

I don't think you want 3 double-quotes in &OUTPATH. In fact, I also don't think you want a double-quote at the start of &OUTPATH and you don't want a double-quote at the end of &OUTPUT either. So remove all three double quotes, fix that and see if it works. 

 

If not, show us the ENTIRE log for this PROC IMPORT (not selected portions of the log, but ALL of the log for PROC IMPORT)

 

For your future benefit, never say "SAS doesn't like it" and provide no other information. We can't help you.

 

ALWAYS show us the log when your code isn't working. Or if the code works but the output is wrong, show us the output and what you expect and explain. Then we can help you.

--
Paige Miller
CadburyAnimal
Calcite | Level 5

Apologies, that was a typo when I re-typed the program into the window. I have updated original message with a screenshot of program + error messages.

CadburyAnimal_1-1652735295955.png

PaigeMiller
Diamond | Level 26

Hi, so I did ask to see the ENTIRE log for PROC EXPORT, not just whatever parts you select.

 

I would also like to see the line where you define the macro variable %let outpath=

--
Paige Miller
CadburyAnimal
Calcite | Level 5

CadburyAnimal_5-1652737142377.png

 

 

CadburyAnimal_4-1652737125108.png

 

 

 

 

PaigeMiller
Diamond | Level 26

Ok, you didn't follow my advice to remove the double-quotes at the start and end of %let outpath=

 

Now, let me explain how macro variables work. When you run the code, the macro variable itself is replaced by its value, and the result must be legal valid working SAS code. You do not have legal valid working SAS code here.

 

Your line of code

 

outfile="&outpath"

 

after replacement, this is your code

 

outfile=""S:/workshop/epg1v2/output""

 

Can you see why this isn't valid code without macro variables? What would you have to do to make it valid code, without macro variables?

--
Paige Miller
CadburyAnimal
Calcite | Level 5
Double quotes on the macro variable - got it. I was concentrating on the output on the proc export (it's late here).
Thanks for your help!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2569 views
  • 1 like
  • 2 in conversation