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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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