BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mariapf
Fluorite | Level 6

Hello all,

 

I have a task that I am having trouble carrying out being a SAS novice but it may be simple after all.

I have some curve names and for each of them I have to create a variable containing two points of the curve. The names of the points are simple to create using a cat function but I cannot figure out how to program an efficient process that creates a new variable with two observations for each observation in the input variable.

 

Thus, in my input table I have:

 

CURVE

curve1

curve2

curve3

 

And I need:

 

CURVE_POINT

curve1_0

curve1_1200

curve2_0

curve2_1200

curve3_0

curve3_1200

 

Should I do this with a loop? If so, how do I specify the need to do the loop for all rows of the curve variable? Counting the number of rows seems to be not so simple in SAS...

 

Thank you so much for your time, it is not easy to be starting out in SAS programming.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input CURVE $;
datalines;
curve1
curve2
curve3
;

data want(drop = point);
   set have;
   do point = 1, 1200;
      curve_point = catx('_', curve, point);
      output;
   end;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input CURVE $;
datalines;
curve1
curve2
curve3
;

data want(drop = point);
   set have;
   do point = 1, 1200;
      curve_point = catx('_', curve, point);
      output;
   end;
run;
mariapf
Fluorite | Level 6

Thanks a lot for your quick reply!

The code that you have suggested worked for both this issue and another table that I was having trouble creating

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 727 views
  • 0 likes
  • 2 in conversation