Statistical programming, matrix languages, and more

How to insert an APPEND command in PROC IML

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

How to insert an APPEND command in PROC IML

Hi all,

 

Given this file,

 

DATA HELLO;

year=2004; deptcode="Sales"; output;

year=2005; deptcode="HR";output;

year=.; output;

year=2007; deptcode="Logistics";output;

run;

 

the following program returns a nice table showing the count of missing and non-missing obs :

 

proc iml;

use HELLO nobs nobs;

read point 1 var _NUM_ into x[colname=nNames];

read point 1 var _CHAR_ into x[colname=cNames];

Names = nNames || cNames;

nmiss = j(1,ncol(Names));

n = nmiss;

do i = 1 to ncol(Names);

read all var (Names[i]) into x;

nmiss[i] = countmiss(x,"col");

n[i] = nobs - nmiss[i];

end;

close HELLO;

rNames = {" Missing", "Not Missing"};

cnt = nmiss // n;

*create beta ;

*append from cnt[r=rNames c=Names label=""];

*close beta;

print cnt[r=rNames c=Names label=""];

quit;

 

I am seeking help to save the output table into a file. I wrote an APPEND command (see three lines in green) but the log keeps yelling at me for an error.

 

Thanks.  


Accepted Solutions
Solution
‎08-23-2016 09:28 AM
SAS Super FREQ
Posts: 3,390

Re: How to insert an APPEND command in PROC IML

create beta from cnt[r=rNames c=Names];
append from cnt[r=rNames];
close beta;

For a discussion ot the CREATE FROM/APPEND FROM syntax, see

"Writing data from a matrix to a data set"

View solution in original post


All Replies
Solution
‎08-23-2016 09:28 AM
SAS Super FREQ
Posts: 3,390

Re: How to insert an APPEND command in PROC IML

create beta from cnt[r=rNames c=Names];
append from cnt[r=rNames];
close beta;

For a discussion ot the CREATE FROM/APPEND FROM syntax, see

"Writing data from a matrix to a data set"

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 200 views
  • 0 likes
  • 2 in conversation