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

Hi Team,

 

How I can convert a numeric value using put and input to comma.

 

var=100000;

 

new_var=100,000;

 

Thanks and regards,

 

JC

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Is that a comma for the 1000/1 million etc separation? Then use the comma format:

new_var = put(var,comma8.);

If more digits are needed, increase the width value accordingly.

View solution in original post

6 REPLIES 6
Reeza
Super User

PUT will create a character variable. I suspect you want a numeric format

 

format variable comma.;

Jcorti
Obsidian | Level 7

No , Actually I want to convert it to char value because I am concatenating with another variable..

I tried and variable needs to be in char format to concatenate with another variable.

So I need to convert it from:

 

var=100000  to new_var=100,000  -->> new_var in char format

Reeza
Super User

When concatenating I recommend using CATT/CATX etc family of functions. They don't require a character variable. 

Jcorti
Obsidian | Level 7
r1=put(input("Range Start"n,15.),comma12.);
r2=put("Range End"n,comma15.);
Range=CATX('_',r1,r2);

Yes I used that function and It worked, thanks for the comment

Kurt_Bremser
Super User

Is that a comma for the 1000/1 million etc separation? Then use the comma format:

new_var = put(var,comma8.);

If more digits are needed, increase the width value accordingly.

Jcorti
Obsidian | Level 7

Thanks Kurt,

It worked 🙂

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
  • 6 replies
  • 4737 views
  • 0 likes
  • 3 in conversation