DATA Step, Macro, Functions and more

assign 1 to the variable Spacec when the value for country contains at least one space

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

assign 1 to the variable Spacec when the value for country contains at least one space

Input country & $16. Team year;

 

run;

 

How to get the value 1 for the country that has at least one space?

 

Thx

 

 


Accepted Solutions
Solution
‎04-16-2018 02:58 PM
PROC Star
Posts: 1,833

Re: assign 1 to the variable Spacec when the value for country contains at least one space

[ Edited ]
value= index(strip(country),' ')>0;
/*for 1,0 binary results*/

if index(strip(country),' ')>0;

if index(strip(country),' ')>0;

View solution in original post


All Replies
Solution
‎04-16-2018 02:58 PM
PROC Star
Posts: 1,833

Re: assign 1 to the variable Spacec when the value for country contains at least one space

[ Edited ]
value= index(strip(country),' ')>0;
/*for 1,0 binary results*/

if index(strip(country),' ')>0;

if index(strip(country),' ')>0;
Contributor
Posts: 20

Re: assign 1 to the variable Spacec when the value for country contains at least one space

Thank you so much for the prompt response.  is work

Frequent Contributor
Posts: 75

Re: assign 1 to the variable Spacec when the value for country contains at least one space

http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n0vxokxhv8lr84n10nrbnzp7gnba.htm&...

 

The documentation above explains what index does

 

Did it work. If yes, you could mark the question as answered and accepted to close the thread.

 

 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 145 views
  • 1 like
  • 3 in conversation