BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
turcay
Lapis Lazuli | Level 10

Hello everyone,

 

How can i create the second data set by using only the first data set? I couldn't get how i could add a new row. I will give values to the ones on the Dq row.

 
Also, Is it possible to create a combobox which forms the values on the q row by using the second data set. I would like to do this with an option like the hlookup on excel. Is it possible to create a workaround on SAS with another method?
 
Data Set 1.png
 
Data Set 2.png
 
Thank you.
 
Can.
 
1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

you could try like below

 

data hvae;
input variable $ value1-value6;
cards;
q .20 .15 .10 .05 .01 .001
;

data want;
set hvae;
array vs1(6) value1-value6;
do i  = 1 to  6;
vs1(i)=vs1(i);
end;
output;
array vs2(6) value1-value6;
variable="1-q";
do i  = 1 to  6;
vs2(i)=1-vs2(i);
end;
output;
array new(6) (1.07 1.14 1.22 1.36 1.63 1.95);
array vs3(6) value1-value6;
variable="Dq";
do z = 1 to 6;
vs3(z)=new(z);
end;
output;
/*format value1-value6 percent10.2;*/
run;
Thanks,
Jag

View solution in original post

7 REPLIES 7
Jagadishkatam
Amethyst | Level 16

you may try using the output statements to output every record. Something like below

 

data hvae;
input variable $ value1-value6;
/*format value1-value6 percent10.2.;*/
cards;
q 20 15 10 5 1 .10
;

data want;
set hvae;
output;
array vs(6) value1-value6;
variable="1-q";
do i  = 1 to  6;
vs(i)=100-vs(i);
end;
output;
run;

Thanks,

Jag

Thanks,
Jag
turcay
Lapis Lazuli | Level 10

 

 

I needed to change raw data to see datas like %20 %15 %10 %5 %1 %0.1. I also couldn't get the created datas like 80.00% 85.00% 90.00% 95.00% 99.00% 99.90%. Is it possible to see format of data like %20 without changing raw data.I also want to see new row's datas like %80.

 

data have;
input variable $ value1-value6;
format value1-value6 percent10.2;
cards;
q .20 .15 .10 .05 .01 .001
;

data want;
set hvae;
output;
array vs(6) value1-value6;
variable="1-q";
*format value1-value6 percent10.2;
do i  = 1 to  6;
vs(i)=100-vs(i);
end;
output;
run;

 

Created Data Set

percent.png

turcay
Lapis Lazuli | Level 10

Also, I would like to know how I can create the values on the Dq row that you can see on the table above by using array. I couldn't do it with the array I have created below.

 

variable="Dq";
do z = 1 to 6;
array new{6} value1-value6(1.07 1.14 1.22 1.36 1.63 1.95);
new(z);
end;
output;
run;
Jagadishkatam
Amethyst | Level 16
The second record issue will be resolved if you simply try vs(i)=1-vs(i);
Thanks,
Jag
turcay
Lapis Lazuli | Level 10

Yes, Thanks a lot. I didn't realize it.

 

As far as i understand i need to change raw data to get datas like %20 etc.

 

Can you also help me about Dq row.How can i add determined datas to Dq row by using array.

 

Thank you.

Jagadishkatam
Amethyst | Level 16

you could try like below

 

data hvae;
input variable $ value1-value6;
cards;
q .20 .15 .10 .05 .01 .001
;

data want;
set hvae;
array vs1(6) value1-value6;
do i  = 1 to  6;
vs1(i)=vs1(i);
end;
output;
array vs2(6) value1-value6;
variable="1-q";
do i  = 1 to  6;
vs2(i)=1-vs2(i);
end;
output;
array new(6) (1.07 1.14 1.22 1.36 1.63 1.95);
array vs3(6) value1-value6;
variable="Dq";
do z = 1 to 6;
vs3(z)=new(z);
end;
output;
/*format value1-value6 percent10.2;*/
run;
Thanks,
Jag
turcay
Lapis Lazuli | Level 10

Thank you for your interest 🙂 Because of you i improved my array skills 🙂

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