Help using Base SAS procedures

Help with getting the average ?

Reply
N/A
Posts: 1

Help with getting the average ?

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?

Super User
Super User
Posts: 7,413

Re: Help with getting the average ?

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;

Super User
Posts: 10,538

Re: Help with getting the average ?

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.

Ask a Question
Discussion stats
  • 2 replies
  • 232 views
  • 0 likes
  • 3 in conversation