I'm using SAS studio (University Edition) on Mac
1) I have several variables that need to be summed together and that resulting sum displayed in summary statistics (and subsequently used for other stats).
E.x. I want to added the following 3 values together to equal "Bobby_hand_cm"
2) How do I combine two values and use the resulting value based on a condition and resulting in a new variable?
Ex: I want to create a code where the person's smoking status (0=never smoked, 1=past smoker, 2=current smoker) is connected to the number of packs smoked per year and equal a new variable ("smoking3")
if smoking status=0 then smoking3=1;
if smoking status=1 and packs per year<20 then smokingg3=2;
if smoking status=1 and packs per year >20 then smoking3=3;
Thanks in advanced for the suggestions! ~J
Bobby_hand_cm=sum(Bobby_palm _cm, Bobby_finger_cm, Bobby_nail_cm);
if smoking_status=0 then smoking3=1; else if smoking status=1 and packs_per_year le 20 then smokingg3=2; else if smoking status=1 and packs_per_year gt then smoking3=3; else;
Show us your data if you want exact code.
Thanks for your help, below
_smkrstat = smoking status
_packyrs = packs per year
(there are no current smokers "2" in this subset). I want the conditional label to be "smkr3"
I guess I didn't need to include the SubID, in there just for my knowledge. Thx~J
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.