BookmarkSubscribeRSS Feed
nannà
Calcite | Level 5

Hi,

I want  show,  before ending DO loop ,the observation N and the vector P  for any i value in data_set

in this proc IML :

proc iml;

M_NP ={1,

    2,

    3,

    4,

    5,

    6};


P= j(1000,1,.);
j=0;
do i=1 to 5;

n= round((M_NP[i+1]-M_NP)* 100);
U= j(n,1,.);
call randgen(U,"uniform");
P[j+1:j+n]= M_NP+(M_NP[i+1]-M_NP)* U;
j=j+n;
end;
quit;

How do i do?

3 REPLIES 3
Rick_SAS
SAS Super FREQ

If you want to print N and P for each iteration, use

print i N P;

Since P has 1,000 rows, this is a lot of printing of mostly missing values. You could also say

print i N (P[j+1:j+n])[label="P"];

nannà
Calcite | Level 5

thank you very much...

but If i want show N and P for each iteration in data set  (the print in output is too long),

how do I do?

Rick_SAS
SAS Super FREQ

You want to create a data set that contains N and P during the loop?

Use the CREATE and APPEND statments like this:

create Out var {N Pi};

do i=1 to 5;

   n= round((M_NP[i+1]-M_NP)*100);

   U= j(n,1,.);

   call randgen(U,"uniform");

   Pi = M_NP+(M_NP[i+1]-M_NP)*U;

   append;

end;

close;

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 962 views
  • 3 likes
  • 2 in conversation