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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1062 views
  • 6 likes
  • 3 in conversation