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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

> 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.

View solution in original post

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

Add something like     create table TEST as    before the select statement.

TRESSQ
Fluorite | Level 6

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!

ChrisNZ
Tourmaline | Level 20

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.]

TRESSQ
Fluorite | Level 6

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:Screenshot 2021-07-20 190037.pngScreenshot 2021-07-20 190107.png

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

ChrisNZ
Tourmaline | Level 20

> 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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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