Search code examples
sas

SAS for academic


I've got an issue with SAS for Academics using web-based when I using statement proc print with by. The output didn't show all value in tobe-group variable as below

Ex: I print table by variable "Country" which have many value: Venezuela, USA,.... but the output only display group of Venezuela

Code:

proc print data=data.customers ;
by country;

enter image description here


Solution

  • Most likely the data is not sorted in ascending order of COUNTRY. That would make a lot of sense when Venezuela is listed as the first country. Check the SAS LOG for an error message like this one:

    1256  proc print data=sashelp.class;
    1257    by sex;
    1258  run;
    
    ERROR: Data set SASHELP.CLASS is not sorted in ascending sequence. The current BY 
           group has Sex = M and the next BY group has Sex = F.
    NOTE: The SAS System stopped processing this step because of errors.
    NOTE: There were 2 observations read from the data set SASHELP.CLASS.
    NOTE: PROCEDURE PRINT used (Total process time):
          real time           0.00 seconds
          cpu time            0.00 seconds
    

    If the data is sorted by DESCENDING order of COUNTRY then tell PROC PRINT that fact.

    proc print data=data.customers ;
      by descending country;
    run;
    

    If it is grouped by country but not actually sorted then use the NOTSORTED keyword.

    proc print data=data.customers ;
      by country notsorted;
    run;
    

    And if it is not even grouped by country then sort it first.

    proc sort data=data.customers ;
      by country ;
    run;
    proc print data=data.customers ;
      by country ;
    run;