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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1455 views
  • 0 likes
  • 3 in conversation