Hi, all.
I try to create frequency about the total, but the SAS said the 'total' variable is not found.
Here's my code
proc import datafile="/home/u58991900/sasuser.v94/Rental_credit_Record.csv"
dbms=csv
out=RRC;
RUN;
proc import datafile="/home/u58991900/sasuser.v94/Rental_Customer_info.csv"
dbms=csv
out=RCI;
RUN;
DATA RRC1;
SET RRC;
IF STATUS="0" THEN GRADE=1;
ELSE IF STATUS="1" THEN GRADE=2;
ELSE IF STATUS="2" THEN GRADE=3;
ELSE IF STATUS="3" THEN GRADE=4;
ELSE IF STATUS="4" THEN GRADE=5;
ELSE IF STATUS="5" THEN GRADE=100;
ELSE IF STATUS="C" OR STATUS="X" THEN GRADE=0;
RUN;
proc print data=RRC1;
run;
proc sql;
Select customer_id,sum(GRADE) as total from RRC1 GROUP BY customer_id;
quit;
title "GraFreq";
proc freq;
tables total;
run;
Is any way I can solve it? ERROR: Variable TOTAL not found.
> I try to figure out the freq of total, but it still does not work when I rub code as I mention
"does not work" doesn't mean much. The proc freq shown will give you the frequency of variable TOTAL.
Add something like create table TEST as before the select statement.
thanks a lot! I run the code as below:
proc sql;
title "Overview";
create table HI AS
Select customer_id,sum(GRADE) as total from RRC1 GROUP BY customer_id;
quit;
It worked!
But when I run the code as followed,
proc freq data= RRC1;
tables total;
run;
It said that the ERROR: Variable TOTAL not found.
should I merge or join the table to 'Rental_credit_Record data' set and run the proc freq data?
Appreciate it!
Now. Which table contains the TOTAL variable?
[the code proc freq was changed compared to when I answered btw, which explains that it doesn't run. Don't do that.]
When I run the proc sql code
proc sql;
title "Overview";
create table HI AS
Select customer_id,sum(GRADE) as total from RRC1 GROUP BY customer_id;
quit;
I mean I just sum the grade and put results in the total column.
Here's a screenshot as followed:
I try to figure out the freq of total, but it still does not work when I rub code as I mention
Proc freq data=HI;
Tables total;
run;
THANK YOU
> I try to figure out the freq of total, but it still does not work when I rub code as I mention
"does not work" doesn't mean much. The proc freq shown will give you the frequency of variable TOTAL.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.