BookmarkSubscribeRSS Feed
☑ This topic is solved. 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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 480 views
  • 6 likes
  • 3 in conversation