BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Amy0223
Quartz | Level 8

Hi community,

I'm not sure if my output is correct for this array problem. Any suggestions are greatly appreciated. Thank you!

 

1. Set up arrays to meet the following requirements:

 Array math has three elements, Jan, Feb and Mar.  Their initial values are “January”, “February” and “March”.
Since the array statement will be the first reference to these variables, pay particular attention to their length.;

 

Below is my answer:

data b;
array math (3) Jan Feb Mar;
do i=1 to 3;
end;
proc print;
run;


Obs	Jan	Feb	Mar	i
1	.	.	.	4

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@Amy0223 wrote:

Hi community,

I'm not sure if my output is correct for this array problem. Any suggestions are greatly appreciated. Thank you!

 

1. Set up arrays to meet the following requirements:

 Array math has three elements, Jan, Feb and Mar.  Their initial values are “January”, “February” and “March”.
Since the array statement will be the first reference to these variables, pay particular attention to their length.;

 

Below is my answer:

data b;
array math (3) Jan Feb Mar;
do i=1 to 3;
end;
proc print;
run;


Obs	Jan	Feb	Mar	i
1	.	.	.	4

 


I think this is not a situation where arrays are needed! But ... it seems as if the answer is expected to contain usage of arrays. And thus a very poor question.

 

Nevertheless

 

array math {3} $ 8 jan feb mar ('January','February','March');
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@Amy0223 wrote:

Hi community,

I'm not sure if my output is correct for this array problem. Any suggestions are greatly appreciated. Thank you!

 

1. Set up arrays to meet the following requirements:

 Array math has three elements, Jan, Feb and Mar.  Their initial values are “January”, “February” and “March”.
Since the array statement will be the first reference to these variables, pay particular attention to their length.;

 

Below is my answer:

data b;
array math (3) Jan Feb Mar;
do i=1 to 3;
end;
proc print;
run;


Obs	Jan	Feb	Mar	i
1	.	.	.	4

 


I think this is not a situation where arrays are needed! But ... it seems as if the answer is expected to contain usage of arrays. And thus a very poor question.

 

Nevertheless

 

array math {3} $ 8 jan feb mar ('January','February','March');
--
Paige Miller
Amy0223
Quartz | Level 8
Thank you very much for your kind help! I greatly appreciate it!
PeterClemmensen
Tourmaline | Level 20

This will do

 

data b;
   array math{3} $ Jan Feb Mar ('January' 'February' 'March');
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 511 views
  • 2 likes
  • 3 in conversation