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!
Your converted variables are in dataset qed_converted (with a _num suffix), but you use dataset availableproducts in the PROC MEANS.
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!
Your converted variables are in dataset qed_converted (with a _num suffix), but you use dataset availableproducts in the PROC MEANS.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.