BookmarkSubscribeRSS Feed
newboy1218
Quartz | Level 8

Hi, I want to create a new variable based on an original variable in my dataset by using the SAS Code node. However, when I wrote the following code into the Score Code panel, it gave me error.

 

data &EM_EXPORT_TRAIN.;
	set &EM_IMPORT_DATA.;
	if MISSING(PYMT_RATIO) then PYMT_RATIO_grp = 1;
	else if NOT MISSING(PYMT_RATIO) and PYMT_RATIO < 0.29 then PYMT_RATIO_grp = 2;
	else if NOT MISSING(PYMT_RATIO) and 0.29 <= PYMT_RATIO AND PYMT_RATIO < 1 then PYMT_RATIO_grp = 3;
	else if (NOT MISSING(PYMT_RATIO) and 1 <= PYMT_RATIO AND PYMT_RATIO < 1.44) or (9999 <= PYMT_RATIO) then PYMT_RATIO_grp = 4;
	else if NOT MISSING(PYMT_RATIO) and 1.44 <= PYMT_RATIO AND PYMT_RATIO < 9999 then PYMT_RATIO_grp = 5;
run;

The error is:

ERROR: Unable to create EMWS1.EMCODE_TRAIN.DATA because EMWS1.EMCODE_TRAIN.VIEW already exists.

 

Does anyone know how I can fix it?

3 REPLIES 3
Reeza
Super User
It looks like EG was creating views, not data sets but you're trying to overwrite the data set as a data set not a view.

You can either create it as a new data set and incorporate that new data into your process (not sure exactly how but I know it's doable) or see if creating it as a view works.

data &EM_EXPORT_TRAIN. / view=&EM_EXPORT_TRAIN.;

https://documentation.sas.com/doc/en/pgmsascdc/v_014/lestmtsref/n1kh25to5o0wmvn1o4n4hsl3yyww.htm#p18...
newboy1218
Quartz | Level 8

Still have error:


ERROR: Write access to member EMWS1.EMCODE_TRAIN.VIEW is denied.
ERROR: Unable to save DATA STEP view EMWS1.EMCODE_TRAIN.

 

How do people usually create new variable (by over-writing the dataset) in SAS EM?

Reeza
Super User
I'm assuming you had the data set closed and everything?
If they've locked it down so that you can't update the automatic data sets, which does make some sense, you need to add the code node as part of your process and then connect that output to your next step. I think SAS is smart enough to use the new data set but if not I think you can modify the source reference in the next task.

It's been a while since I've used EM so going a bit off memory here. You should also be able to contact SAS tech support on Monday morning 🙂

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 choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 825 views
  • 0 likes
  • 2 in conversation