Statistical programming, matrix languages, and more

fonction sample

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

fonction sample

bonjour,

n'étant pas un fin connaisseur de SAS/IML, j"aimerais savoir dans un premier temps quelle est la différence entre SAS/IML et SAS/IML studio.

Par ailleurs, je souhaiterais utiliser la fonction sample et un message d'erreur apparaît m'indiquant qu'elle n'est pas disponible dans ma version de SAS/IML STUDIO (3.4).

Existerait elle donc dans SAS/IML? (je dispose de la version 9.3 de sas?

merci pour vos retours


Accepted Solutions
Solution
‎03-13-2014 02:16 PM
SAS Super FREQ
Posts: 3,227

Re: fonction sample

Hello,

Please excuse me for not responding in French. I do not know the language well.

For a description of SAS/IML Studio, see the 2008 paper or the Introduction to the 2010 paper at         SAS/IML and SAS/IML Studio Papers and Presentations      Briefly,  SAS/IML is the product that you license. It is also the name of a matrix language. PROC IML implements the matrix languiage on the SAS server.  SAS/IML Studio is a development environment that enables SAS/IML programmers to develop SAS/IML programs. SAS/IML Studio runs on a Windows PC. It runs programs in IMLPlus, which is a language that includes SAS/IML syntax plus a Java-like syntax for creating dynamically linked graphics.

The SAMPLE function was introduced in SAS/IML 12.1 (See SAS/IML(R) 12.1 User's Guide).  For SAS/IML 9.3, you can use a function from the book Statistical Programming with SAS/IML Software. See the links in the first paragraph of the article   Sampling with replacement: Now easier than ever in the SAS/IML language - The DO Loop

View solution in original post


All Replies
Solution
‎03-13-2014 02:16 PM
SAS Super FREQ
Posts: 3,227

Re: fonction sample

Hello,

Please excuse me for not responding in French. I do not know the language well.

For a description of SAS/IML Studio, see the 2008 paper or the Introduction to the 2010 paper at         SAS/IML and SAS/IML Studio Papers and Presentations      Briefly,  SAS/IML is the product that you license. It is also the name of a matrix language. PROC IML implements the matrix languiage on the SAS server.  SAS/IML Studio is a development environment that enables SAS/IML programmers to develop SAS/IML programs. SAS/IML Studio runs on a Windows PC. It runs programs in IMLPlus, which is a language that includes SAS/IML syntax plus a Java-like syntax for creating dynamically linked graphics.

The SAMPLE function was introduced in SAS/IML 12.1 (See SAS/IML(R) 12.1 User's Guide).  For SAS/IML 9.3, you can use a function from the book Statistical Programming with SAS/IML Software. See the links in the first paragraph of the article   Sampling with replacement: Now easier than ever in the SAS/IML language - The DO Loop

New Contributor
Posts: 4

Re: fonction sample

Merci Rick! so, i wiill try to speak in english.

First, because of you, i have perfectly understood what IML is. However, i´ve tryed to follow the steps described in your topic about the sampling with and without remplacement by using the sample´s function and it doesn't work ,while it should be possible with sas 9.3

For example, i have this message in the log:

598  proc IML;

NOTE: IML Ready

599  x=1:5;

600  call randseed(325);

601  s_1=sample(x);

ERROR: Invocation of unresolved module SAMPLE.

statement : ASSIGN at line 601 column 1

602  print s_1;

ERROR: Matrix s_1 has not been set to a value.

statement : PRINT at line 602 column 1

SAS Super FREQ
Posts: 3,227

Re: fonction sample

I should have sent you the direct link to the SAS/IML 9.3 module for sampling with replacement: Sampling with replacement in SAS

Your program will look like this:

proc iml;
/* Define module for random sampling with replacement and uniform probability.
  A is row vector with n elements and each sample contains k elements.
  The result is an nSamples x k matrix. Each row contains one sample. */
start SampleReplaceUni(A, nSamples, k);
  results = j(nSamples, k);         /* allocate result matrix */
  call randgen(results, "Uniform"); /* fill with random U(0,1) */
  n = ncol(A);                      /* number of elements */
  results = ceil(n*results);        /* convert to integers 1,2,...n */
  return(shape(A[results], nSamples)); /* reshape and return from A */
finish;

call randseed(1234);
/* Draw 5 elements with replacement from {1,2,...,8}; Repeat 10 times */
s = SampleReplaceUni(1:8, 10, 5);
print s;

New Contributor
Posts: 4

Re: fonction sample

MERCI BEAUCOUP!Smiley WinkSmiley Happy

SAS Super FREQ
Posts: 3,227

Re: fonction sample

Je vous en prie. Bonne chance.

New Contributor
Posts: 4

Re: fonction sample

Hello Rick. I have a last question. I'm starting with sas and i have no experience  to do  programs. What would the program be without remplacement?Thanks

SAS Super FREQ
Posts: 3,227

Re: fonction sample

Your version of SAS is now almost 3 years old. There have been three releases of SAS/IML software since then. If you want the newer features, I encourage you to upgrade your version of SAS.

To gain experience with SAS/IML programming, I recommend the book Statistical Programming with SAS/IML Software.

I do not have a module that does sampling without replacement that works for SAS/IML 9.3. You can use the SURVEYSELECT procedure in SAS/STAT, as shown in this article: Sample without replacement in SAS - The DO Loop

Post a Question
Discussion Stats
  • 7 replies
  • 753 views
  • 5 likes
  • 2 in conversation