- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Run the code.
- Check the log to be sure there are no errors, then save and close the program
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You already gave the answer yourself in your initial post. Just replace the italic string with the string that contains your path.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do you know how to find your EPG194 folder?
Are you able to see files within that folder?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes... thank you all for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your help CYNTHIA. Really appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When you run this, and nothing else appears in the log, then you can safely assume it worked.
To check, run this:
%put &=outpath.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Kurt -
Thank you for your help....I was able to successfully complete the exercise - and output the .csv file to the output folder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
If you have successfully changed your LIBNAME.SAS program, as shown below,these 2 activities are linked:
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:
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:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;