Hi Namrata, Please check the below code proc sql; /*need to delete if a firm appears twice in any year, preferably retain the firm observation with the positive value.*/ create table status as select distinct year,firm,industry, status, count(status) as count from test where status='A' and value > 0 group by year,firm,industry; /*.For each industry each year, I need to count the number of firms that have a positive value(count=A) and the total number of firms.*/ create table count as select distinct status,year,industry,firm,count(status) as count_status,count(firm) as count_firm from status group by year,industry; quit; The dataset count has the desired output. if i understood your requirement correctly you are expecting the below output. could you please check and let me know if this is not the desired output. Thanks, Jag
... View more