Hi all,
I am quite new here as SAS user and i need your help.
Is there any code to identify the variable, if its lowercase or uppercase? Without looking into sashelp.vcolumn?
My goal is, i want to make a list which variable that already uppercase and which one are not.
btw i use SAS enterprise guide
Thank you for your help
WPH
You are a fresh SAS user, I suggest you progress one step at a time. I would try to learn how to write plain SAS code as the first step, then I will learn how to delivery it (Macro). As a rule of thumb, advoid mixing SAS code and Macro like you did. Here, when I say 'wrap my code', I mean 'wrap my code' as is, not 'modify my code then wrap it' :),
%MACRO check_upcase;
data _null_;
set sashelp.vcolumn;
WHERE memname EQ 'ADAE' AND libname EQ 'DERIVED';
IF upcase(name)NE name
then put "WARNING: Please check the dataset check_upcase. Some variable its not UPCASE.";
run;
%MEND check_upcase;
%check_upcase;
Perhaps something like this?
Compare the variable to its upcase equivalent and output accordingly.
data have;
input charvar$;
datalines;
Hello
HELLO
;
data Upcase notUpcase;
set have;
if upcase(charvar)=charvar then output Upcase;
else output notUpcase;
run;
Not entirely sure about your intention, is it value of the variable(see @PeterClemmensen's solution), or is it the name of the variable, since you mentioned metadata 'vcolumns'. SAS, in operation, does not care the case of the variables, however, you can still put it out as being shown below:
data want;
set sashelp.class(keep=age); /*Age came in as Proper case variable*/
AGE_UP=age;/*upper case variable name*/
age_low=age;/*lower case variable name*/
array _age age:;
array po proper upper lower;
do over _age;
/*the show the position of first lower case in the varialble name*/
po=anylower(vname(_age));/*you can also use anyupper() for this purpose*/
end;
run;
Not sure why you need a macro, but your code is unnecessarily complicated, you can wrap up the following code in a macro:
data _null_;
set sashelp.vcolumn;
WHERE memname EQ 'ADAE' AND libname EQ 'DERIVED';
IF upcase(name)NE name
then put "WARNING: Please check the dataset check_upcase. Some variable its not UPCASE.";
run;
You are a fresh SAS user, I suggest you progress one step at a time. I would try to learn how to write plain SAS code as the first step, then I will learn how to delivery it (Macro). As a rule of thumb, advoid mixing SAS code and Macro like you did. Here, when I say 'wrap my code', I mean 'wrap my code' as is, not 'modify my code then wrap it' :),
%MACRO check_upcase;
data _null_;
set sashelp.vcolumn;
WHERE memname EQ 'ADAE' AND libname EQ 'DERIVED';
IF upcase(name)NE name
then put "WARNING: Please check the dataset check_upcase. Some variable its not UPCASE.";
run;
%MEND check_upcase;
%check_upcase;
Ah ok sorry, did not catch that 🙂
I think something is wrong with this statement
"%IF obs. >0 %THEN %DO;"
Is OBS a dataset variable or a macro variable?
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.