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 now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.