BookmarkSubscribeRSS Feed
bismilla
Calcite | Level 5

I want to every second string in upcase

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Do you mean every second word in a string or every second observation?

bismilla
Calcite | Level 5

second observation by using data sets

Shmuel
Garnet | Level 18

data want;

 set have;

       retain flag 0; drop flag;

      array varx $ _character_;

      if flag=0 then do;

         output;

         flag=1;

    end;

    else

    do i=1 to dim(varx);

          varx(i) = upcase(varx(i));

          output;

          flag=0;

     end;

run;

PeterClemmensen
Tourmaline | Level 20
data have;
input string $20.;
datalines;
here
are
some
strings
;

data want;
   set have;
   if mod(_N_, 2)=0 then string=upcase(string);
run;
andreas_lds
Jade | Level 19

Please edit the title and add something meaningful. The word "sas" does not tell anybody anything about the issue you need to be solved.

 

You should although add data in usable format (data step with datalines) and explain. based on the input you show, what do expect as result.

Onizuka
Pyrite | Level 9

@andreas_lds wrote:

Please edit the title and add something meaningful. The word "sas" does not tell anybody anything about the issue you need to be solved.

 

You should although add data in usable format (data step with datalines) and explain. based on the input you show, what do expect as result.


He also has the right to say "Hello" don't you think ? haha

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 6 replies
  • 1204 views
  • 1 like
  • 5 in conversation