BookmarkSubscribeRSS Feed
michtka
Fluorite | Level 6

x
Hi guys, I would like to obtain the next table total:

N       TRT     col0

1        2        Number of subjects

.        1        Number of subjects

I use proc sql to try to get this:

input subjid trt fday  tday;
    datalines;
    1  1 1 5
    2  1 . 4
    2  1 . 3
    3  1 1 4
    3  2 1 -5
    4  2 1 2
    4  1 1 4
    ;
    run;


    proc sql;
   create table total as
   select count(distinct subjid) as n, trt 'Treatment', 'number of subjects' as col0
   from new
   where fday ne . and tday le  0
   group by trt;
   quit;

    proc print data=total noobs; run;

But I obtain only one row:

N   TRT     col0

1    2        Number of subjects

Not appearing the row with missing data.

Can anyone help me to write the code via sql to consider this row with missing data?

Thanks,

V

2 REPLIES 2
Ksharp
Super User

You can't select 1 anymore  because your WHERE condition has already exclude it. But you can get it by your hand.

data new;
input subjid trt fday  tday;
    datalines;
    1  1 1 5
    2  1 . 4
    2  1 . 3
    3  1 1 4
    3  2 1 -5
    4  2 1 2
    4  1 1 4
    ;
    run;


    proc sql;
   create table total as
   select count(distinct subjid) as n, trt 'Treatment', 'number of subjects' as col0
   from new
   where fday ne . and tday le  0
   group by trt
    union 
   select .,1,'number of subjects' from new(obs=1)
;
   quit;

Ksharp

ChrisNZ
Tourmaline | Level 20

Only one row is read from your table.

Only row

 

3 2 1 -5

matches

where fday ne . and tday le  0

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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