Dear SAS Users,
My question maybe basic, but I dared to ask you.
Are there a certain rules of using ":" in the SAS code? I understand well how : helps to explain "all columns that start with..." like in this example when calculating sum:
data quiz_summary;
set pg2.class_quiz;
Name = upcase(Name);
Mean3=mean(of Q:);
run;
However, there are more instances where I saw : , but I am not sure what does it mean there. Please, see this example:
data regions;
input id c :$2. x;
cards;
1 N2 50
2 S1 20
3 N1 100
4 S2 70
5 N1 60
;
data south;
set regions;
if c=:'S';
run;
If you know a document or a book chapter that explains all possible uses of : in SAS, please let me know. I would highly appreciate that!
Marina
Hi @marina_esp The document has compiled your curiosity very well I think. See if this helps when you have time
https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p073-26.pdf
if c=:'S';
When the equal sign is followed by a colon, it means that it is testing to see if the character variable BEGINS WITH the letter or string shown. So, for example, if you wanted to test if a state name begins with the letters NE, you could write
if state_name=:"NE";
which would select states NEVADA, NEW HAMPSHIRE, NEW JERSEY, NEW MEXICO, NEW YORK and NEBRASKA.
This test is case sensitive.
Thank you @PaigeMiller,
Now I see how else we can use : , you resolved my confusion!
Hi @marina_esp The document has compiled your curiosity very well I think. See if this helps when you have time
https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p073-26.pdf
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.