Hi
My code is as below :
%macro pull_offer();
%let start_date = %sysfunc(mdy(1,1,2021));
%last_date = %sysfunc(mdy(1,5,2021));
%do date = &start_date to &end_date;
%let target_day = &date;
format target_day ddmmmyyyyn8.;
%put target_day;
proc sql inobs = 10;
create table contact as
select * from contact_master where mis_dt = &target_day;
quit;
%let path = "temp/offer_data/test" || &target_day || ".csv";
%put path;
proc export data = contact;
outfile = &path;
dbms = csv;
run;
%end;
%mend pull_offer;
%pull_offer;
Please help!!!
The format statement is not valid outside of data steps and procedures. If the variable "mis_dt" is a sas date, formatting will raise other problems. If it is not a sas date, fix that issue first.
The statement
%let path = "temp/offer_data/test" || &target_day || ".csv";
won't work either, macro variable are all strings. So, you need:
%let path = temp/offer_data/test&target_day..csv;
In proc export, you need to wrap the path in quotes.
Hi Still i am getting error as path= or table= statement is required and must be specified...
All macro programming starts with working non-macro code.
Run your SQL and EXPORT steps without any macro coding (no use of macro variables!!), and show us the complete log from that.
Hi @anandmgjsa
Outfile and dbms are both arguments to Proc Export, so don't use semicolons after first and second line.
proc export data = contact;
outfile = &path;
dbms = csv;
run;
Please post the complete log. Copy/paste the log text into a window opened with this button:
HI
I have following code:
I am getting sysntax error in %let path = statement
please help!!
Hi @anandmgjsa,
Please share the full log by copying and pasting it into a post using the "</>" (insert code) icon.
Kind regqards,
Amir.
I merged the questions dealing with the identical issue. Please do not double-post.
Once again: START WITH WORKING NON-MACRO CODE!!!
Once that works, you can make it dynamic, but before the code works without macro coding, your efforts will be futile.
The OUTFILE= option in the PROC EXPORT statement needs a string with a physical path (enclosed in quotes) or a file reference (without quotes).
I see one problem, but that is in proc export: you need to enclose &path in quotes.
If this doesn't solve the problem, remove all macro code and solve all problem, as has be recommended by @Kurt_Bremser multiple times.
Make sure that any sort of directory Path variable starts at a drive (Windows) or disk mount point that is accessible from the machine running SAS. If you do not start at the drive/mount level then the path is a relative and will attempt to find things relative to the current "default" location which may well be in the SAS executable folder.
If you have a server install then the path will be relative to the server, not your machine.
This in addition to the need for Outfile="&path." to properly use it in the Proc Export code.
@anandmgjsa wrote:
HI
I have following code:
I am getting sysntax error in %let path = statement
please help!!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.