Convert SAS code to PROC SQL

Reply
anonymous_user
Posts: 0

Convert SAS code to PROC SQL

Hi,

I need to make a change to the exsiting code but it's written in PORC SQL.

My code (Below) iswritten in SAS. Any idea how I convert the SAS code into PROC SQL so it will just slot into some exisiting code please?

 

proc means data=Additional_Dataset mean;
var pd_long_run;
where current_default ne 'Y';
weight balance_outstanding;
output out=pd mean=;
run;

Trusted Advisor
Posts: 1,228

Re: Convert SAS code to PROC SQL

Something like this may be helpful.

proc sql;

create table pd as

select sum(pd_long_run*balance_outstanding)/sum(balance_outstanding) as Weighted_Avg from

Additional_Dataset

where current_default ne 'Y';

quit;

anonymous_user
Posts: 0

Re: Convert SAS code to PROC SQL

Thanks, but i need it in one statement, probably like a case statement as this is just a one line needed in the middle of the exisiting code.

Somthing like -

mean(case when Current_default ne 'Y' then PD_Long_Run else 0 end) as pd but this doesn't work.


Trusted Advisor
Posts: 1,228

Re: Convert SAS code to PROC SQL

Please provide some sample data.

Ask a Question
Discussion stats
  • 3 replies
  • 301 views
  • 0 likes
  • 2 in conversation