BookmarkSubscribeRSS Feed
NVN
Fluorite | Level 6 NVN
Fluorite | Level 6

Plese help me to ave solution of the following problem.

 

Write a shorter query using SAS arrays to replace '0's as missing values in “Online Orders.csv” dataset. Use asterix(*).

 

7 REPLIES 7
Reeza
Super User

@NVN wrote:

Plese help me to ave solution of the following problem.

 

Write a shorter query using SAS arrays to replace '0's as missing values in “Online Orders.csv” dataset. Use asterix(*).

 


Sounds like homework. How about you post what you've tried and we can help with any issues you have.

Here's a tutorial that may be helpful and probably really has the answer you need:

https://stats.idre.ucla.edu/sas/seminars/sas-arrays/

 

 

NVN
Fluorite | Level 6 NVN
Fluorite | Level 6

Write a shorter query using SAS arrays to replace '0's as missing values in “Online Orders.csv” dataset. Use asterix(*).

 

I executed the following  code.

 

Data online;

set online;

array miss_val=_all_;

if miss_val=0 then miss_val="*";

run;

 

Am using  virtual lab facility for sas.  So  when i execute this query the Error that am seeing is "Unfortunately your server has terminated."

 

when i  use " _numeric_ "    insted of   " _all_ "  the following error is displaying.

ERROR :  Array subscript . out of range [1- 6] of dimension 1 of array miss_val at line 100 and column 4.

 

when i  use " _character_ "    insted of   " _all_ "  the following error is displaying.

ERROR :  Array subscript . out of range [1- 14] of dimension 1 of array miss_val at line 110 and column 4

 

PaigeMiller
Diamond | Level 26

Please take a look at the documentation for the ARRAY statement. At least then you will know the proper syntax for your array statement. http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000201956.htm

 

In that documentation, please see Example 5, it is similar to what you want to do.

--
Paige Miller
Reeza
Super User

1. How do you declare an array - your declaration is incorrect. 

2. You're going to need to lop through the array but you have no loop 

3. The asterisks comment is in reference to declaring an array. 

 

Heres a start for you. Review the link I included above. The first example is almost exactly your question. 

Data want;

Set have;

Array nums (*) _numeric_;

*loop start goes here;

* change to 0 goes here;

*loop end goes here;

Run;
NVN
Fluorite | Level 6 NVN
Fluorite | Level 6

Write a shorter query using SAS arrays to replace '0's as missing values in “Online Orders.csv” dataset. Use asterix(*).

 

I executed the following  code.

 

Data online;

set online;

array miss_val=_all_;

if miss_val=0 then miss_val="*";

run;

 

Am using  virtual lab facility for sas.  So  when i execute this query the Error that am seeing is "Unfortunately your server has terminated."

 

when i  use " _numeric_ "    insted of   " _all_ "  the following error is displaying.

ERROR :  Array subscript . out of range [1- 6] of dimension 1 of array miss_val at line 100 and column 4.

 

when i  use " _character_ "    insted of   " _all_ "  the following error is displaying.

ERROR :  Array subscript . out of range [1- 14] of dimension 1 of array miss_val at line 110 and column

PaigeMiller
Diamond | Level 26

There's no need for multiple threads on the same topic with the exact same question. Let's continue the discussion in your other thread. https://communities.sas.com/t5/SAS-Studio/Arrays/m-p/364040#M2643

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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