BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
adamhyman
Calcite | Level 5

I have this SAS code which is not running, because in the where clause, my variables need to have single quotes around them and '&state.' causes an error.

Any help would be greatly appreciated!!!

%macro linreg(state, var);

     data data_&state_&var;

          set final_rva_5;

          where st_cd eq '&state.' and

               variable eq '&var.';

     x = _N_;

     run;

%mend;

DATA _NULL_;

  SET linreg_state_variable_peril;

  CALL EXECUTE('%LINREG('||linreg_state||','||linreg_variable||','||linreg_peril||');');

RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Macro variables won't resolve inside single quotes.

Why won't double quotes work in the query?

"&state."

View solution in original post

4 REPLIES 4
Reeza
Super User

Macro variables won't resolve inside single quotes.

Why won't double quotes work in the query?

"&state."

adamhyman
Calcite | Level 5

Works like a charm!  Thanks Reeza.

Can I ask you one more question....


What should I be using for &peril._ULT_LR_R_UC?

If I call it with linreg(total), I want the code to be model total_ULT_LR_R_UC = x.

%macro linreg(peril);

     ods output 'Fit Statistics'=fit_statistics
          'Solution'=ParameterEstimates;

          proc glm data=linreg2_data;

               model &peril._ULT_LR_R_UC = x;

               weight &peril._EARNED_UC_PREMIUM;

               run; quit;

          ods output close;

%mend;

Thanks!!!!

Reeza
Super User

I thought that would be it.

&peril._ULT_LR_R_UC

adamhyman
Calcite | Level 5

Thanks Reeza!!

It's working perfectly now   Smiley Happy  Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 884 views
  • 0 likes
  • 2 in conversation