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

Hi All,

 

I have a dataset as below and wondering if there is a way I can use Proc Sql to create the new column Percent. I am trying code below which does not work and it gives me 100% for all values -

 

proc sql;
create table test as select a.*,
( Value/ sum(Value) ) as Percent
from test a
group by month,Range;
quit;

 

 

month Id Value Range Percent
Apr 4 3026 (0,20] 39.0%
Apr 4 1627 (20,60] 21.0%
Apr 4 700 (60,70] 9.0%
Apr 4 2406 (70,80] 31.0%
Aug 8 3275 (0,20] 41.2%
Aug 8 1579 (20,60] 19.9%
Aug 8 669 (60,70] 8.4%
Aug 8 2419 (70,80] 30.5%

 

 

Kind regards

SK

1 ACCEPTED SOLUTION

Accepted Solutions
1 REPLY 1
Haikuo
Onyx | Level 15
Group by month;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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