data cars_subset;
set sashelp.cars;
where upcase(drivetrain)="FRONT";
RUN;
data cars_subset;
set sashelp.cars;
where drivetrain=upcase("front");
RUN;
first one produces 226 obs and 15 columns
and second one produces 0 obs and 15 columns
why it produces two different results ??
and please brief me about how upcase function works like this situation?
Hi @Karim18
The value of the variable DRIVETRAIN in the CLASS data set is "Front".
If you upcase the variable value the result is "FRONT", so the first comparison is true.
But in the second comparison the original variable value "Front" is compared to upcase("front"), also ti "FRONT", which is false.
Hi @Karim18
The value of the variable DRIVETRAIN in the CLASS data set is "Front".
If you upcase the variable value the result is "FRONT", so the first comparison is true.
But in the second comparison the original variable value "Front" is compared to upcase("front"), also ti "FRONT", which is false.
Your first set of code:
where upcase(drivetrain)="FRONT";
Note that DRIVETRAIN and FRONT are both upcased in this filter.
Your second set of code:
where drivetrain=upcase("front");
In this one FRONT is upcased but we don't know if DRIVETRAIN is, unless it was done previously. Given the results, it seems like it's not upcased so both sides of your equal signs are not the same. You could be comparing "Front" to "FRONT" which will not match.
@Karim18 wrote:
data cars_subset;
set sashelp.cars;
where upcase(drivetrain)="FRONT";
RUN;
data cars_subset;
set sashelp.cars;
where drivetrain=upcase("front");
RUN;
first one produces 226 obs and 15 columns
and second one produces 0 obs and 15 columns
why it produces two different results ??
and please brief me about how upcase function works like this situation?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.