BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Hello_there
Lapis Lazuli | Level 10
Data have;
infile datalines dsd dlm=",";
  input name $;
datalines;
Programming,
,
,
Programming,
,
,
Programming,
,
,
;
run;

Hi, How would I get it so the output looks like:

 

Ex:

1. Programming

2. Is 

3. Cool

4. Programming

2. Is

3. Cool

...

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

No worries. See if you can use this as a template

 

Data have;
infile datalines dsd dlm=",";
  input name :$20.;
datalines;
Programming
,
,
Programming
,
,
Programming
,
,
;
run;

data want;
   set have;
   if mod(_N_, 3) = 2 then name = 'Is';
   if mod(_N_, 3) = 0 then name = 'Cool';
run;

View solution in original post

7 REPLIES 7
CarmineVerrell
SAS Employee

hhmmm... is this what you are looking for?

 

Data have;
length name $15;
do j=1 to 1000;
do i=1 to 3;
if i=1 then do; name="Programming"; output; end;
if i=2 then do; name="Is"; output;end;
if i=3 then do; name="Cool"; output;end;
end;
end;

run;

PeterClemmensen
Tourmaline | Level 20

I don't understand this. If that's your logic, then the word 'is' will be in the 2'nd row. And in the 5'th row. Which is not even?

Hello_there
Lapis Lazuli | Level 10

My mistake, but hopefully I made it understandable when I said I was looking for an output that looked like

 

OBS name

1 Programming

2 Is

3 Cool

4 Programming

5 is

6 Cool

....

 

Sorry for the mix up

PeterClemmensen
Tourmaline | Level 20

No worries. See if you can use this as a template

 

Data have;
infile datalines dsd dlm=",";
  input name :$20.;
datalines;
Programming
,
,
Programming
,
,
Programming
,
,
;
run;

data want;
   set have;
   if mod(_N_, 3) = 2 then name = 'Is';
   if mod(_N_, 3) = 0 then name = 'Cool';
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 7 replies
  • 1648 views
  • 6 likes
  • 3 in conversation