BookmarkSubscribeRSS Feed
dewittme
Fluorite | Level 6

Hi,

 

 

I have a data set that has formatting. I would like to do some calculations, then append the the values while keeping the formatted text. What I would like to do is to convert the format text to a text in another column. 

 

MY ideal output would be "class_2" that has all of the text from the formatting for "class" but stored as text. MY actual data isn't this symbol...but that is what I would like to do.

 

DATA toy;
    input class count;
	cards;
	1 5
	2 9
	3 5
	4 13
	;
RUN;

PROC FORMAT;
   value myformat 1 = 'From $1-100'
2 = 'From $101-200'
3 = 'From $201-300'
4 = 'From $301-400';
RUN;

DATA toy;
    SET toy;
	format class myformat.;
RUN;

DATA my_toy;
    SET toy;
	class_2 = put(class, 18.);
RUN;


 

2 REPLIES 2
Reeza
Super User
DATA my_toy;
    SET toy;
	class_2 = put(class, myformat.);
RUN;

Is that what you're trying to do?

 


@dewittme wrote:

Hi,

 

 

I have a data set that has formatting. I would like to do some calculations, then append the the values while keeping the formatted text. What I would like to do is to convert the format text to a text in another column. 

 

MY ideal output would be "class_2" that has all of the text from the formatting for "class" but stored as text. MY actual data isn't this symbol...but that is what I would like to do.

 

DATA toy;
    input class count;
	cards;
	1 5
	2 9
	3 5
	4 13
	;
RUN;

PROC FORMAT;
   value myformat 1 = 'From $1-100'
2 = 'From $101-200'
3 = 'From $201-300'
4 = 'From $301-400';
RUN;

DATA toy;
    SET toy;
	format class myformat.;
RUN;

DATA my_toy;
    SET toy;
	class_2 = put(class, 18.);
RUN;


 



 

dewittme
Fluorite | Level 6

Yep, exactly along those lines, except I don't have access to the myformat format. My real data is a SAV file.

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
  • 2085 views
  • 0 likes
  • 2 in conversation