BookmarkSubscribeRSS Feed
Anmolkhandelwal
Obsidian | Level 7

I have been trying to Declare an array which will be populated with values such as (0.00,25.88,25.10) ,

My declaration Looks like:  ARRAY CP_COB_REMAINING_PAT_LBLTY_AMT {9} 8.2 CP_COB_REMAINING_PAT_LBLTY_AMT1 - CP_COB_REMAINING_PAT_LBLTY_AMT9;

 

After this i am iterating over the aaray and assigning values from my input variable. 

 

Any help?

3 REPLIES 3
andreas_lds
Jade | Level 19

Please post the code using the running-man icon and post the complete data step. From the documentation:

 

Example 2: Assigning Initial Numeric Values

These examples show how to define an array and assign initial numeric values to the elements in the array.

  • array test{4} t1 t2 t3 t4 (90 80 70 70);
  • array test{4} t1-t4 (90 80 2*70);
  • array test{4} _TEMPORARY_ (90 80 70 70);

 

Amir
PROC Star

As well as posting your code as @andreas_lds advised, if you are getting any error or warning messages then please also post your log showing the code executing and the messages generated, using the "Insert Code" icon (denoted by "{i}").

 

Regards,

Amir.

FreelanceReinh
Jade | Level 19

@Anmolkhandelwal wrote:

My declaration Looks like:  ARRAY CP_COB_REMAINING_PAT_LBLTY_AMT {9} 8.2 CP_COB_REMAINING_PAT_LBLTY_AMT1 - CP_COB_REMAINING_PAT_LBLTY_AMT9;

 

Hello @Anmolkhandelwal,

 

The issue with your array declaration is that you specify a format (8.2) where SAS expects a length specification (in your case: 8). Since 8 (bytes) is the default length and numeric is the default type of variables you can even omit this length specification. Also the list of variable names is redundant in your example and can be omitted because an array of the form arrayname[N] consists of variables named arrayname1-arraynameN by default. Remember that there is no "decimal datatype" for variables in SAS datasets. For numbers of all kinds there is only one variable type "numeric" (as opposed to "character").

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
  • 1006 views
  • 0 likes
  • 4 in conversation