Value $age (multilabel notsorted)
LOW - HIGH = "Persons of all ages"
'000'-'004' = "Pre-school children (0-4 years)"
'005'-'012' = "Primary school children (5-12 years)"
'013'-'018' = "Teenagers (13-18 years)"
'019'-'024' = "Young adults (19-24 years)"
'025'-'034' = "Persons ages 25-34 years"
'035'-'044' = "Persons ages 35-44 years"
'045'-'054' = "Persons ages 45-54 years"
'055'-'064' = "Persons ages 55-64 years"
'065'-'074' = "Persons ages 65-74 years"
'075'-high = "Persons ages 75 years and over"
mean (of low-high) = "Average" ;
Bold is where the mistake lies.
Very new to SAS and couldn't figure it out and it was just a guess idea from reading things online. Why won't this work?
And if possible how to I fix it?
As far as I am awre you can't put aggregate functions in a format step. If you want to get means, then look at proc means:
proc means data=have;
var age;
output out=want mean=mean;
run;
A second issue: your format indicates the age variable is text. Means of text aren't going to calculate unless you convert them to numeric. For your format manually calculate it. I wouldn't expect to see that unless you are planning on using a procedure that uses preloadfmt.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.