Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Problem

Status
Not open for further replies.

shenniko

Programmer
Apr 15, 2005
52
US
Hi,

Having a little problem with a Macro.

Every time i run the macro, my SAS session will hang at the very end..

Code:
%Macro Region(FTitle=,Franchise=);
Data &FTitle.;
	set rwork.Restoration_data;
	Where Franchise = "&Franchise.";
	Keep 	Franchise Account_No Workorder Problem_Code Problem_Desc Finding_Code Finding_Desc
			Solution_Code Solution_Desc New_Date_Time New_Close_Date_Time Sched_Date AppFlag;
run;

PROC EXPORT DATA=&FTitle.
            OUTFILE= "T:\TRAC\Robbie\Ofcom\Html\End_User\&FTitle..csv" 
            DBMS=CSV REPLACE;
RUN;

%Mend;
filename Runcode "C:\Ofcom_End_User.SAS";
Data _NULL_;
	set rwork.Merge_Fault_Rate;
	File Runcode;
	Length SubStr $ 500;
	If Franchise NE "All" Then
		SubStr = '%Region(FTitle='||TranWrd(trim(Left(Franchise)), " ","_")||',Franchise='||Trim(Left(Franchise))||');';
	PUT SubStr;
run;
%Inc Runcode;

the above code will run, so it will create datasets for each franchise, and then export the CSV for each dataset.. then when it gets to the very end, SAS will hang...

Can anyone see any problems with the above code?

Thanks in advance

Robbie
 
Found out what the problem was..

for some reason it didnt like the "PROC EXPORT", so i tried using ODS CSV, and it all works fine now..

Shenn
 
Shenniko,
FYI, since you found another way of working this code. The reason that your orig macro code hung was that you have a data step with in another data step. Results can vary. When your macro REGION is called it breaks the Data _NULL_ step that you started. The proc export never gets off the ground and prob hangs the session.

Remember MACRO is only a fancy text generator. You have to imagine the generated code (via the macro) complete. Then you have to say to yourself would that code run if I were to write that with out the macro capability (static). In this case no it would throw a few errors.

Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top