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

Hi my code is showing an error of not being able to find the values:

 

/* New dataset for available products */
data AvailableProducts;
set Qed.Products;
where available = 'T';
run;

/* New dataset for unavailable products */
data UnavailableProducts;
set Qed.Products;
where available = 'F';
run;

/* New dataset for converting grams and rating to numeric values */
Data Qed_Converted;
Set Qed.Products;
rating_num = input(rating, best32.);
grams_num = input(grams, best32.);
run;

/* Descriptive Statistics for available products */
PROC MEANS DATA=AvailableProducts;
VAR grams price rating;
OUTPUT OUT=AvailableStats
MEAN=Avg_grams Avg_price Avg_rating;
RUN;

 

I have converted the character values to numeric still it is showing this!

1 ACCEPTED SOLUTION
4 REPLIES 4
PaigeMiller
Diamond | Level 26

If you are getting errors in the log, show us the ENTIRE log.

 

Otherwise, I don't know what this is referring to.

 


@Adi27 wrote:

 

I have converted the character values to numeric still it is showing this!


 

--
Paige Miller
Adi27
Calcite | Level 5
this is the log: 88 /* Descriptive Statistics for available products */
89 PROC MEANS DATA=AvailableProducts;
90 VAR grams price rating;
ERROR: Variable grams in list does not match type prescribed for this list.
ERROR: Variable price in list does not match type prescribed for this list.
ERROR: Variable RATING not found.
91 OUTPUT OUT=AvailableStats
92 MEAN=Avg_grams Avg_price Avg_rating;
93 RUN;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.AVAILABLESTATS may be incomplete. When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.AVAILABLESTATS was not replaced because this step was stopped.
NOTE: PROCEDURE MEANS used (Total process time):
Kurt_Bremser
Super User

You can streamline your process a lot:

data
  availableproducts
  unavailableproducts
;
set qed.products;
rating_num = input(rating,best32.);
grams_num = input(grams,best32.);
ptice_num = input(price,best32.); drop rating grams price; rename rating_num=rating grams_num=grams
price_num=price ; select (available); when ("T") output availableproducts; when ("F") output unavailableproducts; end; run; proc means data=availableproducts; var grams price rating; output out=availablestats mean=avg_grams avg_price avg_rating ; run;

But you should first ask yourself why the conversions are needed in the first place. Numbers stored in character variables point to a faulty import process which brings the data into SAS, e.g. using a bad medium (Excel files) or PROC IMPORT.