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-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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