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
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.
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.