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

Hi I need help in combining the below two proc sql statements into 1

 

 

data HAVE;
input user_type : $20. Saved policy_no username : $20.;
datalines;
R 1 1 ALUPIYA
R 1 1 ALUPIYA
R 0 2 ALUPIYA
R 1 3 ALUPIYA
I 0 5 DLOUIS
I 1 4 DLOUIS
I 1 4 DLOUIS
O 1 6 DMORAKE
O 1 7 DMORAKE
O 1 8 DMORAKE
O 0 9 DMORAKE

;


data WANT;
input user_type : $20. Total_Saved Total_policies username : $20.;
datalines;
R 2 3 ALUPIYA
I 1 2 DLOUIS
O 3 4 DMORAKE
;

proc sql; 
create table Saves as 
select  user_type,
        username,
        count(distinct policy_no) as total_saved
        from HAVE
		where saved = 1
		group by 1,2
		order by 2
;quit;

proc sql; create table policies_total as
  select user_type,
         username,
         count(distinct policy_no) as Total_Policies
    from HAVE
group by 1,2
order by 2;
quit;

 

1 ACCEPTED SOLUTION
3 REPLIES 3
Solly7
Pyrite | Level 9
Hi Kurt, I have only one dataset which is HAVE..all I need is to have total_saved, total_policies,username, user_type in one dataset

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1039 views
  • 1 like
  • 2 in conversation