DATA Step, Macro, Functions and more

need help with format

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

need help with format

Hi,

Below is my code. What I am trying to do is apply format to salary and the sal_rng column shows the formated value as numeric, is there anyway that I can change the data type to char in the same SQL step. I mean i want the Sal_rng column as Char.

Proc Format;

  Value sallfmt

low-<1200      =  '$0-<$1200'

1200-<5200    =  '$1200-<$5200'

5200-<9200    =  '$5200-<$9200'

9200-<11200  =  '$9200-<$11200'

11200-<15200 = '$11200-<$15200'

15200-high     =  '$15200+'

;

Run

Data a;

Input salary;

cards;

1230

3456

7353

7252

12098

5690

37812

15789

14780

120

11344

;

Run;

Proc Sql;

Create table sal_amt as

select

Salary,

Salary format = salfmt. as Sal_Rng

from

a

;

Quit

Thanks in advance for your help!


Accepted Solutions
Solution
‎03-29-2012 07:44 PM
Respected Advisor
Posts: 4,663

need help with format

Use put()

Proc Sql;

Create table sal_amt as

select

Salary,

put(Salary, salfmt.) as Sal_Rng

from

a

;

Quit;

PG

PG

View solution in original post


All Replies
Solution
‎03-29-2012 07:44 PM
Respected Advisor
Posts: 4,663

need help with format

Use put()

Proc Sql;

Create table sal_amt as

select

Salary,

put(Salary, salfmt.) as Sal_Rng

from

a

;

Quit;

PG

PG
Contributor
Posts: 71

need help with format

PG - It worked. Thanks!!

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 229 views
  • 1 like
  • 2 in conversation