options pageno=1 nodate ls=80 ps=64;
data u1(keep=x);
      seed = 104;
      do i = 1 to 5;
            call ranuni(seed, x);
            output;
      end;
      call symputx('seed', seed);
run;
data u2(keep=x);
      seed = &seed;
      do i = 1 to 5;
            call ranuni(seed, x);
            output;
      end;
run;
data all;
      set u1 u2;
      z = ranuni(104);
run;
proc print label;
      label x = 'Separate Streams' z = 'Single Stream';
run;
Output from the CALL RANUNI Routine
              Separate      Single
Obs      Streams      Stream
1      0.23611      0.23611
2      0.88923      0.88923
3      0.58173      0.58173
4      0.97746      0.97746
5      0.84667      0.84667
6      0.80484      0.80484
7      0.46983      0.46983
8      0.29594      0.29594
9      0.17858      0.17858
10      0.92292      0.92292
Showing posts with label Call Routine. Show all posts
Showing posts with label Call Routine. Show all posts
Monday, November 15, 2010
Monday, December 28, 2009
Call missing
The CALL MISSING routine assigns an ordinary numeric missing value (.) to each numeric variable in the argument list.
The CALL MISSING routine assigns a character missing value (a blank) to each character variable in the argument list. If the current length of the character variable equals the maximum length, the current length is not changed. Otherwise, the current length is set to 1.
You can mix character and numeric variables in the argument list.
prod='shoes';
invty=7498;
sales=23759;
call missing(prod,invty);
put prod= invty= sales=;
prod= invty=. sales=23759
The CALL MISSING routine assigns a character missing value (a blank) to each character variable in the argument list. If the current length of the character variable equals the maximum length, the current length is not changed. Otherwise, the current length is set to 1.
You can mix character and numeric variables in the argument list.
prod='shoes';
invty=7498;
sales=23759;
call missing(prod,invty);
put prod= invty= sales=;
prod= invty=. sales=23759
Sunday, September 6, 2009
CALL SYMPUTX / CALL SYMPUT
CALL SYMPUTX is similar to CALL SYMPUT except that
•CALL SYMPUTX does not write a note to the SAS log when the second argument is numeric. CALL SYMPUT, however, writes a note to the log stating that numeric values were converted to character values.
•CALL SYMPUTX uses a field width of up to 32 characters when it converts a numeric second argument to a character value. CALL SYMPUT uses a field width of up to 12 characters.
•CALL SYMPUTX left-justifies both arguments and trims trailing blanks. CALL SYMPUT does not left-justify the arguments, and trims trailing blanks from the first argument only. Leading blanks in the value of name cause an error.
•CALL SYMPUTX enables you to specify the symbol table in which to store the macro variable, whereas CALL SYMPUT does not. Symbol table is optional and the valid value of it is G, L, and F. If put G, then the macro variable will be stored in the global symbol table; else if specify L, SAS will store the macro in the local symbol table; else if not specify or specify F, SAS follows the same rules as like for Call Symput.
•CALL SYMPUTX does not write a note to the SAS log when the second argument is numeric. CALL SYMPUT, however, writes a note to the log stating that numeric values were converted to character values.
•CALL SYMPUTX uses a field width of up to 32 characters when it converts a numeric second argument to a character value. CALL SYMPUT uses a field width of up to 12 characters.
•CALL SYMPUTX left-justifies both arguments and trims trailing blanks. CALL SYMPUT does not left-justify the arguments, and trims trailing blanks from the first argument only. Leading blanks in the value of name cause an error.
•CALL SYMPUTX enables you to specify the symbol table in which to store the macro variable, whereas CALL SYMPUT does not. Symbol table is optional and the valid value of it is G, L, and F. If put G, then the macro variable will be stored in the global symbol table; else if specify L, SAS will store the macro in the local symbol table; else if not specify or specify F, SAS follows the same rules as like for Call Symput.
Tuesday, June 23, 2009
Call Execute
Data step call routine
call execute('%sales');
call execute('%sales('||month||')');
The following DATA step uses CALL EXECUTE to execute a macro only if the DATA step writes at least one observation to the temporary data set.
call execute('%sales');
call execute('%sales('||month||')');
The following DATA step uses CALL EXECUTE to execute a macro only if the DATA step writes at least one observation to the temporary data set.
%macro overdue; proc print data=late; title "Overdue Accounts As of &sysdate"; run; %mend overdue; data late; set sasuser.billed end=final; if datedue<=today()-30 then do; n+1; output; end; if final and n then call execute('%overdue'); run;
Subscribe to:
Posts (Atom)