@Reeza and @Tom i made this from loud thinking:
Thanks A ton for your help and suggestions to build the code.
this works fine and takes very short time for execution.
%macro city; proc sql noprint; select count (distinct city) into :cdnt from WORK.DAC_3; select distinct city into :city_1 - :city_%left(&cdnt.) from WORK.DAC_3; quit; %let cnt = &cdnt; %put &cnt &cdnt; %do I = 1 %to &cnt; proc export data= WORK.DAC_3 (where=(city = "&&CITY_&I")) outfile= "\\10.4.1.205\Upload\DAC_&&CITY_&I" dbms=xlsx replace; %end; %mend; %city;
@anirudhs wrote:
yes i tried it .... but the excel with city names excel is exporting the whole dataset not the data pertaining to the city only.
If you are trying the CALL EXECUTE() method then compare the code that you generated to what worked when you ran one example.
You should see the code in the SAS log with plus sign between the line numbers and the lines of code.
@Reeza :
Your macro code also is giving error, mentioned
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
WARNING: Apparent symbolic reference WORK not resolved.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: Line generated by the CALL EXECUTE routine.
90 + proc export data=&WORK.DAC_3 (where=(city="ZIRAKPUR")) outfile="\\10.4.1.205\Upload\DAC_FINAL_ZIRAKPUR.xlsx" dbms=xlsx
_
22
76
90 !+replace; run;;
ERROR 22-322: Expecting a name.
ERROR 76-322: Syntax error, statement will be ignored.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.