BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
icrandell
Obsidian | Level 7

I'm writing a macro to allow a user to select a subset of columns in a data table by name and then produce summaries appropriate to the type of the data in the column. The first step is to create a data set with the appropriate names to control a call execute routine. It looks like the following:

 

data varData;
length varnames $20 vardisplays $20;
infile datalines dlm = ",";
input varnames $ vardisplays $;
datalines;
sodium, Sodium (Na)
;

Here, varnames will be the names of the columns in the data set to summarize and vardisplays will be a (possibly long) string to describe the variable. But, I have the following issue:

 

proc sql;
	select * from varData where varnames = "sodium";
quit;

This does not return any rows, even though there's a clearly a "sodium" in the varnames column. This is a problem, because I'll later need to join this data table with sashelp.vcolumn to get the data type of the column in question. What am I doing wrong here? I'm running sas studio version 3.8 and sas version 9.4.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Your code works for me. I ran it without modification, and the SQL returned one line, as expected.

--
Paige Miller

View solution in original post

4 REPLIES 4
Reeza
Super User
Show a query that does work? Is it 'sodium' or 'Sodium', character comparisons are case sensitive.
icrandell
Obsidian | Level 7

I literally copy pasted the string I input in the datalines step into the proc sql. The cases are the same. I would love to write down a query that works but apparently I don't know what data I put into my own data table.

 

If I remove the where clause and just select everything, it shows me a table which looks exactly like the one I input. I can then copy the field "sodium" directly from that table into the where clause and still get nothing. it's as if SAS is storing my text data in some form which is both different from what it's showing me and different from what I gave it.

PaigeMiller
Diamond | Level 26

Your code works for me. I ran it without modification, and the SQL returned one line, as expected.

--
Paige Miller
icrandell
Obsidian | Level 7

Well now that is extremely frustrating. I went and ran the same code on the desktop version and it also worked as expected. Thanks for letting me know it worked for you, I wouldn't have thought the issue could be of this nature.

 

So, looks like the problem is with sas studio. I guess I'll post this on the sas studio forum. 

 

Thanks everyone! Working with sas is always so fun.

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
  • 1218 views
  • 0 likes
  • 3 in conversation