I have a data set that looks like this:
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?
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 -
Please post data in a usable form (hint: pictures ar NOT useful). See my footnotes.
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 -
This is exactly the function I needed
Thank you!
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.