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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 544 views
  • 1 like
  • 2 in conversation