Hi all,
I have one variable, patientfeedbackresponse, in my dataset. I wanted to combine two categories of character variable responses into one (trying to combine 'Retail health clinic' and 'Urgent care center' into a new joint category called 'OSH clinic'). Each time, I try to relabel into a joint variable, I one of the categories comes up as missing. How would you recommend doing this?
Done nothing | 7633 | 39.61 | 10995 | 57.06 |
Emergency room | 206 | 1.07 | 11201 | 58.13 |
N/A | 7019 | 36.42 | 18220 | 94.55 |
Retail health clinic | 270 | 1.40 | 18490 | 95.95 |
Urgent care center | 780 | 4.05 | 19270 | 100.00 |
Thanks
An example of @Reeza's custom format approach.
proc format library=work; value $mylist "Retail health clinic","Urgent care center"="OSH clinic" ; run; proc freq data=have; tables patientfeedbackresponse; format patientfeedbackresponse $mylist.; run;
This format takes advantage of only formatting the values specified. Anything else not used will appear with the current text.
Of course I don't have your data set name, so use yours on the proc freq statement.
Formats used this way create groups as needed. So you could have other formats that combined Emergency room plus these two clinics to a "Any service provider" versus the None and N/A.
The if then statements did not work for me, but this proc format command initially did. However, then when I went to run a regression on the model, it reverted back to the prior separate labels in my logistic regression output. Is there a command that would change the response labels permanently?
The methods both work, so you likely did something incorrect somewhere or didn't specify the correct option. If you post the code we can show you where that was. Perhaps you simply forgot to apply the label to the data set for the regression?
Once you have a format, you can convert it using PUT() but if IF/THEN didn't work, the PUT() conversion won't work either because both are essentially the same approach - recoding the variable. Show your work please.
@jessho wrote:
The if then statements did not work for me, but this proc format command initially did. However, then when I went to run a regression on the model, it reverted back to the prior separate labels in my logistic regression output. Is there a command that would change the response labels permanently?
@jessho wrote:
The if then statements did not work for me, but this proc format command initially did. However, then when I went to run a regression on the model, it reverted back to the prior separate labels in my logistic regression output. Is there a command that would change the response labels permanently?
You need to use the Format in the proc logistic.
If you want to permanently assign the format you can do that manually (not recommended but you can) using the tableview or the SAS Exporere display columns. Or Proc Datasets (recommended for existing data sets). Or rerun a data step with the format assignment.
Or just remember to use the format in the other procedures.
I'm pretty leery about permanently assigning such formats as I might accidently forget that is a formatted value if I don't use the data set for awhile and wonder why it doesn't match the collection documents.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.