DATA Step, Macro, Functions and more

Create new rows from one row on one data set & Use of Combobox on SAS

Accepted Solution Solved
Reply
Super Contributor
Posts: 381
Accepted Solution

Create new rows from one row on one data set & Use of Combobox on SAS

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.
 

Accepted Solutions
Solution
‎10-16-2015 10:55 AM
Trusted Advisor
Posts: 1,128

Re: Create new rows from one row on one data set & Use of Combobox on SAS

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


All Replies
Trusted Advisor
Posts: 1,128

Re: Create new rows from one row on one data set & Use of Combobox on SAS

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
Super Contributor
Posts: 381

Re: Create new rows from one row on one data set & Use of Combobox on SAS

 

 

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

Super Contributor
Posts: 381

Re: Create new rows from one row on one data set & Use of Combobox on SAS

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;
Trusted Advisor
Posts: 1,128

Re: Create new rows from one row on one data set & Use of Combobox on SAS

The second record issue will be resolved if you simply try vs(i)=1-vs(i);
Thanks,
Jag
Super Contributor
Posts: 381

Re: Create new rows from one row on one data set & Use of Combobox on SAS

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.

Solution
‎10-16-2015 10:55 AM
Trusted Advisor
Posts: 1,128

Re: Create new rows from one row on one data set & Use of Combobox on SAS

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
Super Contributor
Posts: 381

Re: Create new rows from one row on one data set & Use of Combobox on SAS

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 305 views
  • 4 likes
  • 2 in conversation