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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotes!

Status
Not open for further replies.

shenniko

Programmer
Apr 15, 2005
52
US
Hi,

I've pulled a list of about 3k Excel Documents in a folder on our network drive.

I want to loop through those documents and DDE in some information (there are about 200+ values in the document but will only list 2 of them below)

The problem im having is when there is an & or a ' in the string, it bombs out of the macro.. Ive tried the %Quote, %NRQuote, %NRBQuote, %str etc.. etc.. and still having no luck with it..

Below is a sample of the code i have:

Code:
%macro Import_I_E(Path=, Doc=, Dmod=, Tmod=, Team=);

    data _null_;
    file xlout;
        put '[error(false)]';
		put '[Open("&Path.&Doc.")]';
	run;

	Filename XLin1 DDE "Excel|&Pth.[&Doc2.]I&E inc portfolio section!R11C5";
	Filename XLin2 DDE "Excel|&Pth.[&Doc2.]I&E inc portfolio section!R12C5";

Data InData2;
	* Account Number;
		Infile XLin1 dlm='09'x notab missover dsd;
		Informat Account 10.0;
		input Account;
		Format Account 10.0;
	*Date;
		Infile XLin2 dlm='09'x notab missover dsd;
		Informat Date ddmmyy10.;
		input Date;
		Format Date Date9.;
	*Modify Date;
		Informat Modified_Date date9.;
		Modified_Date = &Dmod.;
		format Modified_Date date9.;
	*Modify Time;
		Informat Modified_Time time8.;
		Modified_Time = &Tmod.;
		format Modified_Time time8.;
	*Team Folder;
		Informat Team $50.;
		Team = "&Team.";
		Format Team $50.;
output;
run;

%mend Import_I_E;

%Import_I_E(Path=\\F\Forms\I&E forms\2011\06 June\,
			Doc=888745 -O'Shane.XLS, 
			Dmod=18782, 
			Tmod=46380,
			Team=Team 1);

As you can see, there is an & in the Path Variable (so every time i run it tries to compile &E, and a ' in the Doc Variable (and the possibility of an & too)).

Can anyone help me out?

Thanks

Shenn
 
How about you don't use the quotes in your macro but in the macro-call, like so:

%Import_I_E('Path=\\F\Forms\I&E forms\2011\06 June\',
Doc="888745 -O'Shane.XLS",
Dmod=18782,
Tmod=46380,
Team=Team 1)

and then leave them out in the macro itself

put '[Open(&Path.&Doc.)]';

greetings








BIGuidance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top