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

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

Marina Espinasse,
statistician at the University hospital in Northern Norway
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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

 

 

 

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
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.

--
Paige Miller
marina_esp
Obsidian | Level 7

Thank you @PaigeMiller,

 

Now I see how else we can use : ,   you  resolved my confusion!

 

 

Marina Espinasse,
statistician at the University hospital in Northern Norway
novinosrin
Tourmaline | Level 20

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

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 3 replies
  • 617 views
  • 3 likes
  • 3 in conversation