DATA Step, Macro, Functions and more

Array Help: Invalid numeric data

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

Array Help: Invalid numeric data

I need help figuring out where I've gone wrong, please.

 

I have a data set containing 29 observations and 12 variables.  After I import my data set, I see the following {below}. I'm attempting to use an array to clean up data. However, once I enter my code, I'm left with 7 variables and 1 observation. I don't know where I am going wrong and would appreciate help.

Thank you.

 image.png
Libname Clean '/folders/myfolders/Week 11';

proc import datafile='/folders/myfolders/Week 11/BAS150 Survey.xlsx'
	dbms=xlsx
	out=Clean.CleanSurvey;
run;

proc print data=clean.cleansurvey;
run;

proc freq data=clean.cleansurvey;
run;

data clean.cleansurvey;
	array clean{*} preferred_browser read_news online_shopping online_gaming facebook twitter other_social_network;
	do i = 1 TO dim(clean);
		if clean{i}="Eleven" then clean{i}="11";
		if clean{i}=" " then clean{i}=".";
		if clean{i}="Fire Fox" then clean{i}="Firefox";
		if clean{i}="Gogle" then clean{i}="Google";
		if clean{i}="Yohoo" then clean{i}="Yahoo";
		if clean{i}="99" then clean{i}=".";
		if clean{i}="Linked In" then clean{i}="LinkedIn";
	end;
	drop i;
run;

 Log is as follows:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 data clean.cleansurvey;
63 array clean{*} preferred_browser read_news online_shopping online_gaming facebook twitter other_social_network;
64 do i = 1 TO dim(clean);
65 if clean{i}="Eleven" then clean{i}="11";
66 if clean{i}=" " then clean{i}=".";
67 if clean{i}="Fire Fox" then clean{i}="Firefox";
68 if clean{i}="Gogle" then clean{i}="Google";
69 if clean{i}="Yohoo" then clean{i}="Yahoo";
70 if clean{i}="99" then clean{i}=".";
71 if clean{i}="Linked In" then clean{i}="LinkedIn";
72 end;
73 drop i;
74 run;
 
NOTE: Character values have been converted to numeric values at the places given by: (Line)Smiley SadColumn).
65:15 65:29 66:15 66:24 67:15 67:31 68:15 68:28 69:15 69:28 70:15 70:25 71:15 71:32
NOTE: Invalid numeric data, 'Eleven' , at line 65 column 15.
NOTE: Invalid numeric data, 'Fire Fox' , at line 67 column 15.
NOTE: Invalid numeric data, 'Gogle' , at line 68 column 15.
NOTE: Invalid numeric data, 'Yohoo' , at line 69 column 15.
NOTE: Invalid numeric data, 'Linked In' , at line 71 column 15.
NOTE: Invalid numeric data, 'Eleven' , at line 65 column 15.
NOTE: Invalid numeric data, 'Fire Fox' , at line 67 column 15.
NOTE: Invalid numeric data, 'Gogle' , at line 68 column 15.
NOTE: Invalid numeric data, 'Yohoo' , at line 69 column 15.
NOTE: Invalid numeric data, 'Linked In' , at line 71 column 15.
NOTE: Invalid numeric data, 'Eleven' , at line 65 column 15.
NOTE: Invalid numeric data, 'Fire Fox' , at line 67 column 15.
NOTE: Invalid numeric data, 'Gogle' , at line 68 column 15.
NOTE: Invalid numeric data, 'Yohoo' , at line 69 column 15.
NOTE: Invalid numeric data, 'Linked In' , at line 71 column 15.
NOTE: Invalid numeric data, 'Eleven' , at line 65 column 15.
NOTE: Invalid numeric data, 'Fire Fox' , at line 67 column 15.
NOTE: Invalid numeric data, 'Gogle' , at line 68 column 15.
NOTE: Invalid numeric data, 'Yohoo' , at line 69 column 15.
NOTE: Invalid numeric data, 'Linked In' , at line 71 column 15.
NOTE: Invalid numeric data, 'Eleven' , at line 65 column 15.
NOTE: Invalid numeric data, 'Fire Fox' , at line 67 column 15.
NOTE: Invalid numeric data, 'Gogle' , at line 68 column 15.
NOTE: Invalid numeric data, 'Yohoo' , at line 69 column 15.
NOTE: Invalid numeric data, 'Linked In' , at line 71 column 15.
NOTE: Invalid numeric data, 'Eleven' , at line 65 column 15.
NOTE: Invalid numeric data, 'Fire Fox' , at line 67 column 15.
NOTE: Invalid numeric data, 'Gogle' , at line 68 column 15.
NOTE: Invalid numeric data, 'Yohoo' , at line 69 column 15.
NOTE: Invalid numeric data, 'Linked In' , at line 71 column 15.
NOTE: Invalid numeric data, 'Eleven' , at line 65 column 15.
NOTE: Invalid numeric data, 'Fire Fox' , at line 67 column 15.
NOTE: Invalid numeric data, 'Gogle' , at line 68 column 15.
NOTE: Invalid numeric data, 'Yohoo' , at line 69 column 15.
NOTE: Invalid numeric data, 'Linked In' , at line 71 column 15.
preferred_browser=11 read_news=11 online_shopping=11 online_gaming=11 facebook=11 twitter=11 other_social_network=11 i=8 _ERROR_=1
_N_=1
NOTE: The data set CLEAN.CLEANSURVEY has 1 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
75
76 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
89

Accepted Solutions
Solution
‎03-29-2017 09:16 PM
PROC Star
Posts: 7,363

Re: Array Help: Invalid numeric data

I haven't looked closely at your code but, in your final datastep, there is no set statement.

 

I would think you should have, as your second line, included a statement like:

 

set clean.cleansurvey;

Art, CEO, AnalystFinder.com

 

View solution in original post


All Replies
Solution
‎03-29-2017 09:16 PM
PROC Star
Posts: 7,363

Re: Array Help: Invalid numeric data

I haven't looked closely at your code but, in your final datastep, there is no set statement.

 

I would think you should have, as your second line, included a statement like:

 

set clean.cleansurvey;

Art, CEO, AnalystFinder.com

 

Occasional Contributor
Posts: 17

Re: Array Help: Invalid numeric data

Thank you. That worked!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 224 views
  • 0 likes
  • 2 in conversation