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
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.
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?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.