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

Hi! How should I answer this question below? Any help is greatly appreciated!

 

Count the number of times the string '?' occurs in variable line. Choose any method that works reliably. Regardless of method, assume that a line won't consist entirely of '?'s.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @Amy0223 

 

You can use the countc() function for example:

var2 = countc(var1,'?');

 

View solution in original post

3 REPLIES 3
Reeza
Super User

Try and find a function here that will count the number of characters. 

The documentation has an example for the function towards the bottom of page.

 

Hint: You want to COUNT a character. 

 

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=allprodsle&docsetTarget=s...

 


@Amy0223 wrote:

Hi! How should I answer this question below? Any help is greatly appreciated!

 

Count the number of times the string '?' occurs in variable line. Choose any method that works reliably. Regardless of method, assume that a line won't consist entirely of '?'s.

 


 

ed_sas_member
Meteorite | Level 14

Hi @Amy0223 

 

You can use the countc() function for example:

var2 = countc(var1,'?');

 

Amy0223
Quartz | Level 8
Great! I got it. Thank you very much!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3739 views
  • 2 likes
  • 3 in conversation