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.
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;
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
Thank you Jagadishkatam,
You really helped me in the best way.
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
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;
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.
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;
Thank you for your interest 🙂 Because of you i improved my array skills 🙂
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!
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.