01-20-2013 05:55 AM
I am currently creating a macro to execute some analysis, and I am passing as parameters the name of the variables I want to use for the test (i.e.: the dependent and independent variables).
I am adding TITLE and FOOTNOTE lines to my code that should mention the variables being used. However, instead of using &var1 or &var2 to get the name of the variables used, I would like to use the label of the variables being used.
Is there a way to pull the label for the variables from the variable name?
01-20-2013 07:12 AM
Yes, but it depends how you want to access it. e.g., you could get it from dictionary.columns:
proc sql noprint;
select label into :label
where libname="WORK" and
There are also vlabel and vlabelx functions.
01-20-2013 09:45 AM
I would create new variables that contain the values you are looking for and use thoes as BY variables. You can put them in the TITLES/FOOTNOTES using the #BYval/var directives. Create the new variables with VLABEL/VNAME or PROC TRANSPOSE
01-23-2013 05:52 AM
Thank you for trying to help.
I am totally new to SAS so I am struggling to understand the suggestions.
Arthur: I am not using PROC SQL in my code, so I am having a hard time understanding the bis and bulbs of you example and if/how I could use it in my macro.
dat_null__: I am not sure how to use the VLABEL/VNAME statement and the #BYval/var directives.
Here is my macro code in case it helps:
%MACRO twot(dataSrc, depVar, factVar);
TITLE "Hypothesis Test - H0: Mean &depVar by factor &factVar are equal";
PROC TTEST DATA=&dataSrc;
Instead of showing the variable names for &depVar and &factVar, I would like instead to show their label. So if I pass on ROI_Y1 as a depVar (dependent variable) then in the title I would like it to say Return of Investment Year 1 rather than ROI_Y1.
Thanks for helping me with this one.
01-23-2013 08:59 AM
This example does not use #BY directives. It creates two new macro variables to hold the labels. If you want to also use the variable names as I did the CALL SYMPUTX to redefine those variable insures that when the value are printted they are "spelled" the same as in your data set.
If you have many variable pairs you could transpose your data such that you have BY variables for the VARs and LABELs. If you want to see that post some sample data.