0

When should I use single quotes and when should I use double quotes in SAS?

I have encountered one case where it makes a big difference. What is the reasoning behind this difference?

Example that works:

%let y = 1999;
data test;
set fxmicro.aug99;
where date_time > "02aug&y. 09:30:00"dt;

run;

With single quotes it doesn't work. Error message:

ERROR: Invalid date/time/datetime constant '02aug&y. 09:30:00'dt.

I typically use single quotes myself when I write SAS-code.

What is the guidlines for using double quotes?

Dagfinn Rime
  • 67
  • 2
  • 8

1 Answers1

0

Macro expressions aren't evaluated when they are inside single quotes, that's why you need to use double quotes here.

In most other situations with SAS, double and single quotes are interchangeable. Note that you need to pay attention to any restrictions imposed by the database that you are querying (some databases treat single and double quotes differently).

snozza
  • 2,123
  • 14
  • 17