BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
devarayalu
Fluorite | Level 6

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Keith
Obsidian | Level 7

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

2 REPLIES 2
LinusH
Tourmaline | Level 20

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

Data never sleeps
Keith
Obsidian | Level 7

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.);

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

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