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

Hi y'all,

Please help create a group variable risk [i] in data step to my existing set of dataset.

where: 

median of data is 300

risk[1]=300/3

risk[last]=300*3

by interval of 10.

 

The range has to be 300/3-300*3 with median of 300.

 

data temp; set agerisk;
  array risk {i};
  do i=1 to dim[risk];
  ...
  end;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Cruise wrote:
Thanks a lot for getting back to me. I want:
risk val
1 100
2 200
3 300
4 400
5 500
6 600
7 700
8 800
9 900
10 1000
11 1100
12 1200
13 1300
14 1400
15 1500

That looks like you want to create a val as 100* risk. Which would be:

data want;
   do risk=1 to 15;
      val = Risk*100;
      output;
   end;
run;

View solution in original post

4 REPLIES 4
Cruise
Ammonite | Level 13

What am i doing wrong here? I simply want two variables created to the same number of rows in a new dataset?

 

data c.temp;
do risk=1 to 15 by 1;
do val=100 to 1500 by 100;
end;
end;
output;
run; 
ballardw
Super User

@Cruise wrote:

What am i doing wrong here? I simply want two variables created to the same number of rows in a new dataset?

 

data c.temp;
do risk=1 to 15 by 1;
do val=100 to 1500 by 100;
end;
end;
output;
run; 

Hard to tell what you  are doing wrong with out knowing what the output should look like.

 

But if you want output for each iteration the OUTPUT has to be inside one of the loops. likely

 

data c.temp;
   do risk=1 to 15 by 1;
      do val=100 to 1500 by 100;
         output;
      end;
   end;
run; 
Cruise
Ammonite | Level 13
Thanks a lot for getting back to me. I want:
risk val
1 100
2 200
3 300
4 400
5 500
6 600
7 700
8 800
9 900
10 1000
11 1100
12 1200
13 1300
14 1400
15 1500
ballardw
Super User

@Cruise wrote:
Thanks a lot for getting back to me. I want:
risk val
1 100
2 200
3 300
4 400
5 500
6 600
7 700
8 800
9 900
10 1000
11 1100
12 1200
13 1300
14 1400
15 1500

That looks like you want to create a val as 100* risk. Which would be:

data want;
   do risk=1 to 15;
      val = Risk*100;
      output;
   end;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1174 views
  • 0 likes
  • 2 in conversation