BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
whymath
Lapis Lazuli | Level 10

Run the two code samples from SAS Help Center , both of them failed.

The first one:

%macro setvar;
   %let dsid=%sysfunc(open(sasuser.houses, i));
      /* No leading ampersand with %SYSCALL */ 
   %syscall set(dsid); 
   %let rc=%sysfunc(fetchobs(&dsid, 10));
   %let rc=%sysfunc(close(&dsid));
%mend setvar;
%global price style;
%setvar
%put _global_;

Log shows:

WARNING: Argument 1 to function SET referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.

GLOBAL PRICE
GLOBAL STYLE

The second one:

data mydata;
      /* create variables for assignment */
      /*by CALL SET */
   length style $8 sqfeet bedrooms baths 8 
      street $16 price 8;
   drop rc dsid;
   dsid=open("sasuser.houses", "i");
   call set (dsid);
   do i=1 to 10;
      rc=fetchobs(dsid, i);
      output;
   end;
run;

Log shows:

NOTE: Variable style is uninitialized.
NOTE: Variable sqfeet is uninitialized.
NOTE: Variable bedrooms is uninitialized.
NOTE: Variable baths is uninitialized.
NOTE: Variable street is uninitialized.
NOTE: Variable price is uninitialized.
NOTE: Argument 1 to function SET(0) at line 18 column 9 is invalid.
style=  sqfeet=. bedrooms=. baths=. street=  price=. dsid=0 i=11 rc=70021 _ERROR_=1 _N_=1
NOTE: The data set WORK.MYDATA has 10 observations and 7 variables.

And dataset WORK.MYDATA are all missing values.

 

I use 9.4M7 and 9.4M8, see the same result.

What happend to CALL SET routine?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

This part is the key one:

NOTE: Argument 1 to function SET(0) at line 18 column 9 is invalid.

You don't show the line numbers with the data step but I will place a wager of a small stack of $$$ bils that line 18 is:

   call set (dsid);

DSID has the numeric value of 0. Whis is what the OPEN function returns with the data set is not found.

 

Almost all the better code involving the OPEN and related functions includes bits about checking the results for values >0 and branch of execute when true or a note and recovery code.

 

I know that my SAS install does not have a SASHELP.HOUSES data set. Either use one that actually exists or make one in your work library. Not all of the online examples run as entered in the help. Some use data sets only available with specific installed modules.

 

View solution in original post

3 REPLIES 3
ballardw
Super User

This part is the key one:

NOTE: Argument 1 to function SET(0) at line 18 column 9 is invalid.

You don't show the line numbers with the data step but I will place a wager of a small stack of $$$ bils that line 18 is:

   call set (dsid);

DSID has the numeric value of 0. Whis is what the OPEN function returns with the data set is not found.

 

Almost all the better code involving the OPEN and related functions includes bits about checking the results for values >0 and branch of execute when true or a note and recovery code.

 

I know that my SAS install does not have a SASHELP.HOUSES data set. Either use one that actually exists or make one in your work library. Not all of the online examples run as entered in the help. Some use data sets only available with specific installed modules.

 

Tom
Super User Tom
Super User

You do not appear to have a dataset named SASUSER.HOUSES.

 

Personally I never put datasets into the SASUSER library since it is normally readonly because I usually run with the -RSASUSER initialization option so SAS will use my SASUSER.PROFILE for settings instead of making and using WORK.PROFILE.

 

Try using SASHELP.CLASS and the variables it contains, NAME SEX AGE HEIGHT WEIGHT.

 

whymath
Lapis Lazuli | Level 10
You guys are right, blame me for not checking the existence of the dataset.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 472 views
  • 3 likes
  • 3 in conversation
OSZAR »