BookmarkSubscribeRSS Feed
Gryphxn
Calcite | Level 5

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?

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

ballardw
Super User

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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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