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

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):(Column).
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
1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

2 REPLIES 2
art297
Opal | Level 21

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

 

bldudley
Obsidian | Level 7

Thank you. That worked!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 1570 views
  • 0 likes
  • 2 in conversation