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

I am trying to implement the K-means Clustering algorithm. I imported the data set(CREDIT) to sas  ,  replaced the missing values (NA) with 0 of the variable that i need  ( MonthlyIncome ) but variable have the character data type.  But when i try to convert this variable to numeric to do the Scaling process  with the following code the log is showing the following errors. please help me..

 

error 1: Found " Monthly_Income"  when expecting  " ;"

error2: Statement "Monthly_Income" is not valid;

 

Code:

Proc standerd data=CREDIT mean=0 std=1;

out=CREDIT1;

var  age MonthlyIncome debtratio etc...............;

Var Monthly_Inc=(MonthlyIncome, best12.);

run;

 

4 REPLIES 4
stat_sas
Ammonite | Level 13

Hi,

 

First convert variable in data step and then standardize. 

NVN
Fluorite | Level 6 NVN
Fluorite | Level 6

Data step..?  you mean..? at the time of importing the data set to sas.?  or  change the type directly.?

ballardw
Super User

@NVN wrote:

Data step..?  you mean..? at the time of importing the data set to sas.?  or  change the type directly.?


Best would be to insure that the data was read into SAS as a numeric.

If that isn't practical for some reason you can use a data step to change:

 

data want;

   set have (rename=(income=textincome));

   income = input(textincome,best10.);

  /* assign format or labels as desired*/

   drop textincome;

run;

 

the rename is so you could use the same varaible name as you cannot change sas data types directly.

NVN
Fluorite | Level 6 NVN
Fluorite | Level 6

It is working..  Thank you  soo much guys.

 

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