BookmarkSubscribeRSS Feed
ydu180
Calcite | Level 5

The requirement is: Print a table containing the number of observations, median, mean, and standard deviation for temperatures for each of the two days individually. 

 

The output I got is WechatIMG250.jpegDoes anyone know how to show like this WechatIMG251.jpeg

data hw6.hotdays_ydu18;
   infile "/home/ydu180/hw6/hourly_temps.txt" dlm=' ';
   do Day=1 to 2;
      do Hour=1 to 24;
         input Temp@@;
         output;
      end;
   end;
run;

/*d*/
title2"Part 3d";
proc means data=hw6.hotdays_ydu18 N Median Mean STD;
   var Temp:;
   by Day;
run;
3 REPLIES 3
Kurt_Bremser
Super User

Use the output statement in proc means to create a new dataset, and use proc print from that.

 

For further help, post the .txt file as attachment, or copy/paste it into a {i} window

Ksharp
Super User

If you have SAS9.4 , try SQL instead.

 

proc sql;
select day,count(*) as N,median(temp) as median,mean(temp) as mean,std(temp) as std
 from have
  group by day;
quit;
ballardw
Super User

One way:

proc tabulate data=hw6.hotdays_ydu18;
  class day;
  var temp;
  table day,
        n='Nobs' temp*(N Median Mode STD);
run;

Options available to specify different formats do control number of displayed digits.

 

The first n='Nobs' will show the count of the DAY variable value, the second is non-missing Temp values.

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 3851 views
  • 0 likes
  • 4 in conversation