THANKS FOR YOUR REPLY! I found another way to use it as a reference if you need it
proc ds2;
data s / overwrite=yes;
drop j;
declare varchar(16) ds2_array[2,5];
declare double ds2_arrayo[5];
declare varchar(16) ds2_array1 ds2_array2 ;
dcl double ds2_array3 j;
method run();
ds2_array:=(
'parmcard','Alfred','Alice','Barbara ','Carol ','f','f','f','f','f');
ds2_arrayo:=(1.1,2.1,3.1,4.1,5.1);
do j=1 to dim(ds2_array,2);
ds2_array1=ds2_array[1,j];
ds2_array2=ds2_array[2,j];
ds2_array3=ds2_arrayo[j];
output;
end;
end;
enddata;
run;
quit;
Why not use parmcards instead.
options parmcards=mycards;
filename mycards temp;
parmcards4;
Alfred M 14 69 112.5
Alice F 13 56.5 84
Barbara F 13 65.3 98
Carol F 14 62.8 102.5
;;;;
Now later in your DS2 code you can use INFILE MYCARDS.
@Tom wrote:Why not use parmcards instead.
options parmcards=mycards; filename mycards temp; parmcards4; Alfred M 14 69 112.5 Alice F 13 56.5 84 Barbara F 13 65.3 98 Carol F 14 62.8 102.5 ;;;;
Now later in your DS2 code you can use INFILE MYCARDS.
I've tried your method and it says a "parsing failed" issue, but I've found another way that can be used as a reference if you need it
proc ds2;
data r;
method run();
infile mycard;
end;
enddata;
run;
quit;
The right way is next code
proc ds2;
data s / overwrite=yes;
drop j;
declare varchar(16) ds2_array[2,5];
declare double ds2_arrayo[5];
declare varchar(16) ds2_array1 ds2_array2 ;
dcl double ds2_array3 j;
method run();
ds2_array:=(
'parmcard','Alfred','Alice','Barbara ','Carol ','f','f','f','f','f');
ds2_arrayo:=(1.1,2.1,3.1,4.1,5.1);
do j=1 to dim(ds2_array,2);
ds2_array1=ds2_array[1,j];
ds2_array2=ds2_array[2,j];
ds2_array3=ds2_arrayo[j];
output;
end;
end;
enddata;
run;
quit;
According to the SAS Blog <Reasons to love PROC DS2>:
DS2 is not a replacement for the DATA step as INFILE, INPUT, FILE, PUT, and DATALINES statements aren’t permitted.
But you can use variable assignment statement and output statement.
proc ds2;
data one(overwrite=yes);
declare int x;
method run();
x=1;
output;
end;
enddata;
run;
quit;
THANKS FOR YOUR REPLY! I found another way to use it as a reference if you need it
proc ds2;
data s / overwrite=yes;
drop j;
declare varchar(16) ds2_array[2,5];
declare double ds2_arrayo[5];
declare varchar(16) ds2_array1 ds2_array2 ;
dcl double ds2_array3 j;
method run();
ds2_array:=(
'parmcard','Alfred','Alice','Barbara ','Carol ','f','f','f','f','f');
ds2_arrayo:=(1.1,2.1,3.1,4.1,5.1);
do j=1 to dim(ds2_array,2);
ds2_array1=ds2_array[1,j];
ds2_array2=ds2_array[2,j];
ds2_array3=ds2_arrayo[j];
output;
end;
end;
enddata;
run;
quit;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.