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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 831 views
  • 1 like
  • 4 in conversation