where category variable has :
in
out
middle
Are these both notations correct to select all the value starting with in???
if category eq: "in" then....
if category eq "in:" then....
Thanks
The colon is a modifier on the comparison operator, not on the value.
if category eq: "in" then ...
If you are using WHERE instead of IF then you could use LIKE operator:
where category like 'in%' ;
i was confused because we use colon operator beisde variable name to pick the variable names starting with the specified
like
if we have variables var1 to var50
we can just write for example( keep =var:)
how is this:
if category eq: "in" then ... different from the above????
Hi,
Take a look at this: 24851 - Using a Colon Modifier to Select Observations with Values Beginning with a Specific Characte... or from the doc (SAS(R) 9.3 Language Reference: Concepts, Second Edition) "You can add a colon (:) modifier to any of the operators to compare only a specified prefix of a character string."
Or, you can write a program to prove to yourself how the different syntax elements would work.
cynthia
data colon_mod;
infile datalines;
input string $;
test1 = 'n';
test2 = 'n';
test3 = 'n';
if string =: 'in' then test1 = 'y';
if string = 'in' then test2 = 'y';
if string = 'in:' then test3 = 'y';
return;
datalines;
inert
input
in
inagadda
nothing
;
run;
ods listing;
proc print data=colon_mod;
run;
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.
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.