BookmarkSubscribeRSS Feed

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;

3 REPLIES 3
stat_sas
Ammonite | Level 13

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;

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.


stat_sas
Ammonite | Level 13

Please provide some sample data.

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
  • 3 replies
  • 581 views
  • 0 likes
  • 2 in conversation