BookmarkSubscribeRSS Feed
Junhui1
Calcite | Level 5

Dear Expert:

 

My program is as below. When I run the program the first time, I found that the name column is upper case , but subsequently I  run the program, the name column became mixed case. We already know that Libname and Memname are stored in the views in upper case. But for name, does capitalization changes all the time? 

Could you please help on this issue, thank you!

 

data test1;
set sashelp.vcolumn;
where LIBNAME = "WORK" and MEMNAME =upcase("TEST");
run;

4 REPLIES 4
sbxkoenk
SAS Super FREQ

Hello,

As long as the metadata of the columns is not changing, capitalization is constant of course (but , for name , can be mixed case indeed).
Use upcase function to make your query case insensitive:

data test1;
set sashelp.vcolumn;
where LIBNAME = "SASHELP" and MEMNAME = "CLASS"
      and upcase(name)="HEIGHT";
run;

Koen

 
Junhui1
Calcite | Level 5

Hi Koen,

 

Thanks for your reply! I am sorry that, in my question, I forgot to describe one thing. It's that before run this proc sql, I will run the program to output 'TEST' dataset first. But the code for 'TEST' dataset didn't not change, I just rerun it. After that, I ran this proc sql, then the case of name changed. I am not sure if this is related to the code for 'TEST' dataset. But the first time I run these code, it will get the uppercase 'name'.

ballardw
Super User

@Junhui1 wrote:

Hi Koen,

 

Thanks for your reply! I am sorry that, in my question, I forgot to describe one thing. It's that before run this proc sql, I will run the program to output 'TEST' dataset first. But the code for 'TEST' dataset didn't not change, I just rerun it. After that, I ran this proc sql, then the case of name changed. I am not sure if this is related to the code for 'TEST' dataset. But the first time I run these code, it will get the uppercase 'name'.


When you rerun code you replace the data set. So changes can happen on variable descriptions. If you aren't changing anything why are you rerunning your code?

You would have to provide the log from ALL code that creates or modifies the data set WORK.TEST in your current session to convince me that just "reran" without changes. 

For example, Proc Datasets can change variable properties such as names and labels without affecting the code ran that creates the set.

Also if the code that creates Work.Test involves macro variables then the actual values of those macro variables may have changed the case of the name. If Work.Test is the output of a procedure then the input to the procedure may have changed.

If you are reading external data files with a tool such as Proc Import then variable names may change because the source files differed.

The above paragraph likely does not address all possibilities.

Kurt_Bremser
Super User

The most important thing I have learned from my time at IT support are these most-often told lies:

"I didn't do anything"

"I didn't change anything"

😉

 

Mind that, most often, these lies are not told consciously.

 

During the creation of variables, the case of variable names is set.

So

data test;
X = 1;
run;

and

data test;
x = 1;
run;

may be completely equivalent, but they will create upper- and lowercase variable names, respectively.

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 638 views
  • 0 likes
  • 4 in conversation