DATA Step, Macro, Functions and more

how to count and output specific number of strings in a variable

Accepted Solution Solved
Reply
Contributor
Posts: 43
Accepted Solution

how to count and output specific number of strings in a variable

 

Accepted Solutions
Solution
‎01-31-2018 10:42 AM
SAS Moderator
Posts: 48

Re: how to count and output specific number of strings in a variable [how to improve your question]

Posted in reply to sas_student1

Hello @sas_student1,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @draycut

.

View solution in original post


All Replies
Solution
‎01-31-2018 10:42 AM
SAS Moderator
Posts: 48

Re: how to count and output specific number of strings in a variable [how to improve your question]

Posted in reply to sas_student1

Hello @sas_student1,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @draycut

.
Contributor
Posts: 43

Re: how to count and output specific number of strings in a variable [how to improve your question]

Posted in reply to Community_Guide

can you remove this post please.

I did not finish my post and accidently posted it.

I have a new post with the full question

Trying to figure out how to remove this one and cant seem to find the delete option

Super User
Posts: 13,066

Re: how to count and output specific number of strings in a variable

Posted in reply to sas_student1

The function COUNTW may work depending on how well you define "number of strings".

Of course that is for a single observation.

Do you mean to count across observations?

 

Example input data and example output for the given input will help provide more specifics.

 

Issues that can affect this sort of count are quoted strings with imbedded delimiters to count as one "string", Strings with delimiters such as period  (is library.dataset to be counted as one string or two?), numeric values with commas and or decimals (is 3,456.7 to be one word, two or 3?)

Presence of special characters such as * / ()%@ and should they be treated as word separators or not.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 81 views
  • 0 likes
  • 3 in conversation