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

Hi;

I'm currently preparing to take the Base Programming Certification. I downloaded 4 pages of exercises which I found somewhere on the SAS website (see attached file).

 

I'm having an issue with project 2: I can answer question 4 correctly, but not Question 3 (Question 3: How many observations are classified into the “Lower” group? ). With my code:

data new;
set sashelp.shoes;
length salesrange $10.;
if (Sales >=0 AND sales < 100000) then salesrange="Lower";
else if (Sales >= 100000 AND Sales<= 200000) then salesrange="Middle";
else if sales > 200000 then salesrange="Upper";
run;

proc print data=new;
where salesrange = "Lower";
run;

my answer for question 3 is 394, not, as the paper says, 288. Is this an error on the paper or did I make a mistake?

Any help is appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc freq data=new;
    tables salesrange;
run;

produces this output

 

                                                                                  Cumulative    Cumulative
                                           salesrange    Frequency     Percent     Frequency      Percent
                                           ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
                                           Lower              288       72.91           288        72.91
                                           Middle              60       15.19           348        88.10
                                           Upper               47       11.90           395       100.00

 

so I would say the answer is 288. Your PROC PRINT has observation 394 as the last observation, but the observation numbers are not consecutive so there are not 394 observations printed. Also, the log for your PROC PRINT shows:

 

138   proc print data=new;
139   where salesrange = "Lower";
140   run;

NOTE: There were 288 observations read from the data set WORK.NEW.
      WHERE salesrange='Lower';
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


so 288 observations were printed.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
proc freq data=new;
    tables salesrange;
run;

produces this output

 

                                                                                  Cumulative    Cumulative
                                           salesrange    Frequency     Percent     Frequency      Percent
                                           ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
                                           Lower              288       72.91           288        72.91
                                           Middle              60       15.19           348        88.10
                                           Upper               47       11.90           395       100.00

 

so I would say the answer is 288. Your PROC PRINT has observation 394 as the last observation, but the observation numbers are not consecutive so there are not 394 observations printed. Also, the log for your PROC PRINT shows:

 

138   proc print data=new;
139   where salesrange = "Lower";
140   run;

NOTE: There were 288 observations read from the data set WORK.NEW.
      WHERE salesrange='Lower';
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


so 288 observations were printed.

--
Paige Miller
Sandra_Ilja
Calcite | Level 5
Arghh, I'm such a newbie 😞 Thanks so much! This really drove me nuts.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1209 views
  • 1 like
  • 2 in conversation