Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Age varible as character variable and with the formatted values. Is it possible if so pls suggest the way?

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

Age varible as character variable and with the formatted values. Is it possible if so pls suggest the way?

data sasuser.demog;

   input subject race age sex $1. eth trt;

datalines;

   1 2  6 M 2 1

   2 4  0 M 4 2

   3 1 33 F 1 1

   4 2 38 F 2 2

   5 4  2 F 4 1

;

   run;

proc format library=sasuser;

   value $age   0-17='<18'

               18-29='18-29'

               30-39='30-39'

               40-49='40-49';

run;

options fmtsearch=(sasuser);

PROC TABULATE DATA=sasuser.demog out=sasuser.demog1(drop= _table_ _page_ _type_);

   class trt age/preloadfmt;

   format age age.;

   table age, trt all/printmiss;

RUN;

By this code I am getting age numeric variable but with formatted values. I want the same dataset but that age varible as character variable and with the formatted values. Is it possible if so pls suggest the way?


Accepted Solutions
Solution
‎01-16-2013 06:38 AM
Regular Contributor
Posts: 151

Re: Age varible as character variable and with the formatted values. Is it possible if so pls suggest the way?

just run a data step with the put statement to create a new variable with the formatted values

length age_band $10;

age_band =put(age,$age.);

View solution in original post


All Replies
Super User
Posts: 5,255

Re: Age varible as character variable and with the formatted values. Is it possible if so pls suggest the way?

Try specify discrete values for age (not intervals) in your format specification.

Data never sleeps
Solution
‎01-16-2013 06:38 AM
Regular Contributor
Posts: 151

Re: Age varible as character variable and with the formatted values. Is it possible if so pls suggest the way?

just run a data step with the put statement to create a new variable with the formatted values

length age_band $10;

age_band =put(age,$age.);

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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