DATA Step, Macro, Functions and more

struggling to recognise quote characters in macro?

Reply
Valued Guide
Posts: 2,175

struggling to recognise quote characters in macro?

well I was

struggling to recognise quote characters in macro

I just couldn't seem to make the example in the online doc work for me
..
..
..
..
step back a little
..
..
..
rather than test a single quote

which is what is causing me trouble
..

,..
(a light started to blink on.. )
..
I remembered the base SAS dequote() function

It strips of pairs of quotes without needing me to use that symbol :-)

this worked for me[pre]
%if %sysfunc(dequote(&memname)) EQ &memname %then %do ;
%* it is not quoted so get on with it ! ;
Regular Contributor
Posts: 241

Re: struggling to recognise quote characters in macro?

I went through a similar struggle. Mine was making a macro so that it can accept a date literal both with the quotes and trailing d and without. My solution was using prx shown on sas-l. See the macro %date2num():
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1007A&L=sas-l&P=R1001
Frequent Contributor
Posts: 106

Re: struggling to recognise quote characters in macro?

Ditto. In my case it was a macro that served as a dynamic allocation front-end on the mainframe. The coder's intent was to support MVS datasetnames to be passed with either single or double quotes. Jumping through SUBSTR hoops he had been able to come up with a double quoted macro variable value. Fine for SAS 8.2 where he had developed it, but fraught with WARNINGs/NOTEs with SAS 9.1.3 which turned out to be a little pickier about the doubled double quotes that sometimes ended the variable's value.

Replacing all the SUBSTR logic with DEQUOTEs made the code cleaner and easier to read, the WARNINGs/NOTEs go away and so ultimately the SAS log much cleaner.
Ask a Question
Discussion stats
  • 2 replies
  • 135 views
  • 0 likes
  • 3 in conversation