Hello I havent used SAS in a while, and want to attain a basic programmer cert.
I'm trying to get this grouping to work from sashelp.cars but it is giving me all 128 observations in the output. I see repeated valuesfor the BY variable make
proc sort data=sashelp.cars out=work.temp2 (keep = make);
by make;
run;
proc print data = work.temp2;
any suggestions?
The option is nodupkey.
If your familiar with SQL then use proc sql:
proc sql; create table WANT as select MAKE, sum(MSRP) as RES from SASHELP.CARS group by MAKE; quit;
Yes, by group just means to do something for each group specified, it doesn't remove any variables. Perhaps you mean to sort the dataset using nodupkey:
proc sort data=sashelp.cars out=work.temp2 (keep = make) nodupkey; by make; run; proc print data = work.temp2; run;
The nodupkey options will remove any subsequent observations from each by group.
thanks so much-
If I wanted to sum msrp against Make grouping how would I go about that?
my code below is still giving me all 428 obs in the output.
proc sort data=sashelp.cars out=work.temp2 (keep = make msrp);
by make;
run;
proc print data = work.temp2;
sum msrp;
run;
The option is nodupkey.
If your familiar with SQL then use proc sql:
proc sql; create table WANT as select MAKE, sum(MSRP) as RES from SASHELP.CARS group by MAKE; quit;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.