BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9

I have a proc sql statement that I'm trying to check if a variable is null or not.

proc sql ;

create table x

as

select id, case when Search = 'Yahoo' then '<a href="www.yahoo.com">Yahoo</a>' || ' ' ||    ??????

quit ;

At this point I want to replace ?????? with a way to check my variable to see if there is data or not.  If there is I want to add more text if not then continue to the next step.

I want to add brackets around my value if it isn't null.

Ex. The variable has data :  Yahoo  [Bob]

Ex. The variable no data :  Yahoo

Thanks

4 REPLIES 4
ballardw
Super User

when missing(variablename) then ...

would be the general approach

jerry898969
Pyrite | Level 9

Ballardw,

Thanks for the reply.  Would that when belong to another case statement?

Within this contatnation i'm doing there will be multiple variables that could be null and if they are I don't want the text that identifies them to display.  I want it to display only if there is data.

Thanks

ballardw
Super User

Another case statement at this point. I'm not sure how many levels of nesting SAS SQL will handle. It may be worth looking into a datastep at least for manipulating the individual variables to have the [] or whatnot done to them and then an appropriate CATX CATS or whichever to concatenate them into one variable to insert in to the final string.

jerry898969
Pyrite | Level 9

Ballardw,

Thank you so much.  I'm going to start out the morning trying to use a data step.  I think with an if statement and catx or cats I can get it working that way.

I will reply my results.

Thanks

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7402 views
  • 3 likes
  • 2 in conversation