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: 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
  • 3675 views
  • 2 likes
  • 3 in conversation