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

I have a data set that looks like this:

 

image.png

 

Where "response" is a formatted column (actual values are numeric: 1,2, 3). I have the correct format in the "format" column, as text. 

 

I would like to do something like

 

 

DATA desired;

    SET current_data;

    question_fmt = put(response, format);

RUN;

Here I want the format supplied to the put argument to come from the format column. IS there a way to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Oligolas
Barite | Level 11

Hi,

 

you can use the vvalue function (Returns by Default a $200 length if not specified)

DATA desired;
    SET current_data;
    question_fmt = vvalue(Response);
RUN;
________________________

- Cheers -

View solution in original post

4 REPLIES 4
Oligolas
Barite | Level 11

Hi,

 

you can use the vvalue function (Returns by Default a $200 length if not specified)

DATA desired;
    SET current_data;
    question_fmt = vvalue(Response);
RUN;
________________________

- Cheers -

dewittme
Fluorite | Level 6

This is exactly the function I needed

 

Thank you!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post test data in the form of a datastep and what you want to see out.  How are you going to store the output text with the format, as formats apply to the whole variable?  You could use a text field of course.

I suspect what you are after is the putc and putn functions.  Then you pass the variable, the format name, and optionally length across:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212562.htm

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1433 views
  • 1 like
  • 4 in conversation