BookmarkSubscribeRSS Feed
Deepai
Calcite | Level 5

I have 400 clusters (20,000 observations). I want to get proportion of smokers in each cluster (Smoking vs non-smoking) as a separate variable in the same data set for each cluster.  I would really appreciate the help from helping hands. 

 

Thanks

 

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

DUPLICATE THREAD

 

DO NOT REPLY HERE

 

Reply at: https://communities.sas.com/t5/SAS-Programming/Calculating-proportion/td-p/623140 where there is already one answer.

--
Paige Miller
ballardw
Super User

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

The example data only needs to include the variables needed to identify a cluster and your smoking variable.

 

Then show what you expect as a result.

In the same data set is possibly not a good idea as mixing summaries and observation values has the potential for oddness when someone forgets which variable is a summary. Can you describe exactly why you need the summary proportion on each record?

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1490 views
  • 0 likes
  • 3 in conversation