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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

2 REPLIES 2
PGStats
Opal | Level 21

Use put()

Proc Sql;

Create table sal_amt as

select

Salary,

put(Salary, salfmt.) as Sal_Rng

from

a

;

Quit;

PG

PG
vicky07
Quartz | Level 8

PG - It worked. Thanks!!

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 875 views
  • 1 like
  • 2 in conversation