BookmarkSubscribeRSS Feed
kc10
Calcite | Level 5

 

Follow the instructions for your software to create a macro variable that stores the location for output files.

SAS Studio

 

  • In your EPG194 folder, open libname.sas.

  • Create a macro variable named outpath that stores the filepath to your EPG194/outputfolder:

 

 

%let outpath=filepath-to-output-folder; 
  1. Run the code.

  2. Check the log to be sure there are no errors, then save and close the program
21 REPLIES 21
kc10
Calcite | Level 5
How do you create a macro variable named outpath that stores to your EPG194/outputfolder? I am having trouble.. don't know what to do from the beginning. Will appreciate your help to walk me through.
kc10
Calcite | Level 5

Thank you so much for your help. 

Astounding
PROC Star
Questions to get you started:

Do you know how to find your EPG194 folder?

Are you able to see files within that folder?
kc10
Calcite | Level 5

Yes... thank you all for your help.

Cynthia_sas
SAS Super FREQ

Hi:

  In SAS Studio, right click on the OUTPUT folder under your EPG194 main folder. Choose Properties. In the location field, the full path should be revealed to you. Highlight and copy this path with Ctrl+C. then highlight the italics (shown in pink below):

%let outpath=filepath-to-output-folder; 

and replace (Ctrl+V) the highlighted string with the path location you copied from Properties. Possibilities for all the different ways to use SAS are:

Most frequently used free methods:

SAS University Edition: %let outpath=/folder/myfolders/EPG194/output;

SAS OnDemand for Academics: %let outpath=/home/<your_userid>/EPG194/output;

   OR                                          %let outpath=~/EPG194/output;

 

 

Other methods of using SAS:

C: drive with local SAS: %let outpath=C:\SAS_class\EPG194\output;

Unix Installation: %let outpath=/usr/bin/SAS_class/EPG194/output;

Enterprise Guide: %let outpath = %sysfunc(pathname(work)); (no write access to C: drive)

  OR            %let outpath = c:\SAS_class\EPG194\output;  (with write access to C: drive)

 

Any time in the course where you have seen the string 'FILEPATH' or 'filepath-to-folder', you've needed to replace that string with a path location -- usually the path to the data folder. The only difference here is that you are using the locatioin of the OUTPUT folder.

 

Hope this helps,

Cynthia

kc10
Calcite | Level 5

Thank you for your help CYNTHIA. Really appreciated!

thyes83
Calcite | Level 5

I am struggling getting past this first step of defining a file path using the %let macro code.  Specifically, after running the code (SAS Studio - University Edition), with the correct path, the code runs but I cannot see anything in the log to indicate the macro variable was created.  When calling in the macro variable in the Proc Export activity - the program does not recognize the &outpath macro so no table is produced.  I tried a few different ways of running the %let to define the &outpath macro variable and proc export program to produce the pg1.storm_final SAS table but cannot get past this exercise.

 

Quick question, after running the following exercise - the following code - what should I see in the log?  How do I know the &outpath macro variable was successfully created and available to use in the proc export exercise?

%let outpath=/folders/myfolders/EPG1V2/output;

  

thyes83
Calcite | Level 5

Kurt -

 

Thank you for your help....I was able to successfully complete the exercise - and output the .csv file to the output folder. 

Cynthia_sas
SAS Super FREQ

Hi:

  If you have successfully changed your LIBNAME.SAS program, as shown below,these 2 activities are linked:

Cynthia_sas_1-1604523270093.png

Once you update LIBNAME.SAS with the %LET statement and run the code, assuming that you have the correct location of your OUTPUT folder, the macro variable should resolve correctly. You can use the %PUT statement to verify the value of &OUTPATH, as shown below:

Cynthia_sas_2-1604523524034.png

 

 

However, if you spelled the folder path wrong, the %PUT doesn't do you any good here. What really matters is whether the output file got exported correctly to the /folders/myfolders/EPG1V2/output folder when you run the code to create the storm_final.csv file. In my SAS log, it shows in the NOTES what the value of &outpath was, how it was used and whether the program code was successful. You can see the resolved name in the LOG messages below:

Cynthia_sas_0-1604523238300.png

 I hope this helps clarify that when we refer to using &OUTPATH, we expect that you have done the required setup for creating the macro variable. As shown in my code, for SAS University Edition, assuming you made the data according to the instructions, your data folder full path should be:

/folders/myfolders/EPG1V2/data

and the output folder full path should be:

/folders/myfolders/EPG1V2/output

 

Cynthia

 

smatholi
Fluorite | Level 6
I tried hard but no success. please help. I am getting the below error

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 194.37k
OS Memory 33708.00k
Timestamp 16/02/2021 11:33:08 PM
Step Count 162 Switch Count 0
Page Faults 0
Page Reclaims 16
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0

NOTE: The SAS System stopped processing this step because of errors.
73 proc export data=pg1.storm_final
74 outfile= "&outpathone/test_file.csv"
NOTE: Line generated by the macro variable "OUTPATHONE".
74 ""/EPG194/output"
_
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, DATA, DBLABEL, DBMS, DEBUG, FILE, LABEL, OUTFILE, OUTTABLE, REPLACE,
TABLE, _DEBUG_.

ERROR 76-322: Syntax error, statement will be ignored.

75 dbms=csv replace;
76 run;
77
78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
90
SASKiwi
PROC Star

It looks like you have wrapped the macro variable OUTPATHONE's value in unbalanced quotes. It shouldn't need quotes at all:

%let OUTPATHONE = /EPG194/output;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 21 replies
  • 5917 views
  • 9 likes
  • 10 in conversation