Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:05:13+00:00 2026-06-11T04:05:13+00:00

I have variable1 with strings such as asdfsad What do you do, qwer What

  • 0

I have variable1 with strings such as "asdfsad What do you do", "qwer What is your name", "Zebra"

And variable2 with strings "asdfsad", "qwer", "Animal"

I want to remove the first word from the strings in variable1 if it equals the word in variable2. The only thing I can come up with so far is to replace each word separately:

i.e. variable1=tranwrd(variable1, "asdfsad", ""); etc. however I have many words to replace.

Many thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:05:15+00:00Added an answer on June 11, 2026 at 4:05 am

    How about something like this:

    data sample;
      length variable1 variable2 $100;
      variable1= "asdfsad What do you do"; variable2 = "asdfsad"; output;
      variable1= "qwer What is your name"; variable2 = "qwer";    output;
      variable1= "Zebra"                 ; variable2 = "Animal";  output;
    run;
    
    data fixed;
      length first_word $100;
    
      set sample;
    
      first_word = scan(variable1,1);
      if first_word eq variable2 then do;
        start_pos = length(first_word) + 1;
        variable1 = substr(variable1,start_pos); 
      end;
    run;
    

    This will work for matching on the entire first word. It leaves the spaces or other punctuation in the remaining text but you should be able to change that easily if you like.

    If your problem is to match character-by-character and not on the entire first word then that would be a very different question and I would recommend posting a new question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number of url's with different query strings such as view.php?id=5 view.php?id=6
I have several strings which look like the following: <some_text> TAG[<some_text>@11.22.33.44] <some_text> I want
I have a spinner that is populated with a list of strings such as
I have class implementing Comparator<String> which should sort strings in such manner that strings
I have an array that collects strings of questions passed as such: $myQuestionsPass =
I have a list of strings.. each one looks similar to this: \n\t\BLOCK\,\HEADER-\\r\n\t\t\NAME\,\147430\\r\n\t\t\REVISION\,\0000\\r\n\t\t\DATE\,\11/11/10\\r\n\t\t\TIME\,\10:03:47\\r\n\t\t\PMABAR\,\\\r\n\t\t\COMMENT\,\\\r\n\t\t\PTPNAME\,\0805C\\r\n\t\t\CMPNAME\,\0805C\\r\n\t\BLOCK\,\PRTIDDT-\\r\n\t\t\PMAPP\,1\r\n\t\t\PMADC\,0\r\n\t\t\ComponentQty\,4\r\n\t\BLOCK\,\PRTFORM-\\r\n\t\t\....(more).... What
I have a variable $next which contains strings that might contain parenthesis e.g trna(tgc)
I have a variable length array of strings declared in javascript that contains Dungeons
I have an two variables as CSV strings. Example: $csva = 1,4,7,10,39,12; $csvb =
I have a variable that contains : Sometimes array of strings and sometimes array

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.