BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

 

data lemon;
  input food $ fooder $;
datalines;
apple applepie
run;


data test output=test1;
set lemon;
y=index(fooder,"pie");
run;
proc print data=test1;
run;


how can I also have y in my output table test1?

3 REPLIES 3
SASKiwi
PROC Star

The correct syntax for this is:

data test test1;
set lemon;
y=index(fooder,"pie");
run;

Test and Test1 will be identical and both contain y.

HeatherNewton
Quartz | Level 8
if index(segment, "QHKG") then 
total = total _bad_count

originally I thought this statement is about if we can look for QHKG in segment, however if it exist QHKG will be a positive interger indicating its position, if not found, I will get a zero, so how does this statement work? when does total=total_bad_count? when it is not zero? 

Astounding
PROC Star
SAS evaluates numeric values as being true or false. It considers zero and missing values to be false, and any other value to true.

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