Hi,
I have a sas dataset that has some variables that was not presenting frequencies. The variables are named and label like this; U-METHADONE, U-OXY, U-FENTANYL.
How can I resolve this problem.
proc freq data = original_data;
tables U-METHADONE;
run;
*LOG;
I have attempted to rename the variables but no luck.
data new_data;
set original_data (rename=(U-METHADONE=Methadone));
keep Methadone ;
run;
*LOG;
Thanks
Variable names cannot have a dash (hyphen) in the variable name.
You can override this with the following option:
options validvarname=any;
and then you can refer to variables in your code with dash in their name as, for example,
tables 'U-METHADONE'n;
Variable names cannot have a dash (hyphen) in the variable name.
You can override this with the following option:
options validvarname=any;
and then you can refer to variables in your code with dash in their name as, for example,
tables 'U-METHADONE'n;
Hyphens are not allowed in valid variable names. It thinks you are trying to do some type of variable list, but the syntax is not right for that either as for a variable list using a single hyphen you need names with a numeric suffix.
If you have the validvarname option set to ANY (why?) then you need to use a Name Literal to reference a variable name that does not follow normal naming rules.
tables "U-METHADONE"n;
Otherwise if you have validvarname=v7 then you are probably trying to use the LABEL of the variable where you should be using the NAME of the variable.
Show us the output of PROC CONTENTS on this data set for these variables.
Thank you. The problem is solved. I still sent you a snippet of the proc content if you still need it.
Thanks! But as long as the problem is solved, the PROC CONTENTS is no longer needed.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.