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

data RandClass(drop=i);
call streaminit(1234);
set sashelp.cars(keep=Cylinders Horsepower Enginesize);
array x {*} _numeric_;
do i = 1 to dim(x);
   if rand("Bern", 0.1) then         /* p=0.4 ==> about 40% missing */
      x[i]=.; end;
run;
proc print;
run;

data sashelp;
set sashelp.cars;
update cars Randclass;
by Cylinders Horsepower Enginesize;
run;
proc print cars;

 

 

I have removed data values randomly from three variables cylinders horsepower and enginesize from sashelp.cars. when i am trying to update newly created varaibles with missing value in data set sashelp.cars its giving me errors like

 
67 data sashelp;
68 set sashelp.cars;
69 update cars Randclass;
ERROR: File WORK.CARS.DATA does not exist.
70 by Cylinders Horsepower Enginesize;
71 run;
proc print cars;
____
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, BLANKLINE, CONTENTS, DATA, DOUBLE, GRANDTOTAL_LABEL, GRANDTOT_LABEL,
GRAND_LABEL, GTOTAL_LABEL, GTOT_LABEL, HEADING, LABEL, N, NOOBS, NOSUMLABEL, OBS, ROUND, ROWS, SPLIT, STYLE,
SUMLABEL, UNIFORM, WIDTH.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
 
can anyone help me in this errors which is coming when i am trying to update. half part is working correct even i am getting as an output randclass dataset with 3 variables. in the 2nd part when i am trying to update its giving me errors.
Reeza
Super User

The error is clear, do you have a dataset CARS created, check your library? If not then check your code. I think you meant to create a dataset called CARS but you called it SASHELP instead? Make sure you're consistent with the names used. 

art297
Opal | Level 21

Your code won't work for a number of reasons. For one you select every cell, as the random number will always be greater than 0, thus the condition will always be true.

 

Second, you never create the file cars but, rather, a file called sashelp

 

Art, CEO, AnalystFinder.com

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 17 replies
  • 3917 views
  • 2 likes
  • 7 in conversation