12-08-2015 06:14 AM
12-08-2015 07:01 AM - edited 12-08-2015 07:02 AM
66 %if &dsid ne 0 %then %sysfunc(attrn(&dsid,&attribute));
What you try to do in this line?
You are using attrn with wrong attr-name ? chk : ATTRN Function valid attr-name
Where is varnum in your code?
In which variable you will keep the %sysfunc(); values? I think you are missing a %let in this line.....
12-09-2015 10:39 AM - edited 12-09-2015 10:40 AM
If you are going to use ATTRN Function
Then you need to use valid attr-name with it in the second argument like NOBS, ANY ........ other mentioned on the link above
So for example your code may look like:
%if &dsid ne 0 %then %put %sysfunc(attrn(&dsid,nobs));
12-09-2015 11:56 AM - edited 12-09-2015 11:56 AM
I also think once you fix the attribute parameter in the attrn() function, you will get a syntax error at line 67 with "%else ¬found;". Are you trying to put the notfound macro variable into another variable, or are you trying to print the value of the notfound macro variable to the log? If you leave it as is, the code will resolve to %else . or %else ' ', depending on the value of the type macro variable. SAS will read this and give you a syntax error.
If you are wanting to print the value of the notfound macro variable to the log, you will need to add a "%put" in front of the ¬found. If you are wanting to put the value of the notfound macro variable into another variable or a data set, you will need to add another %let statement setting a variable equal to ¬found or have a data step with the variable notfound put into a field. Hope this helps!
12-10-2015 06:52 AM
12-10-2015 09:18 AM
When you say "variable attribute", do you mean the variable type (Character/Numeric), Length, Format, etc..? You could always run a proc contents and output it to a data set and limit that data set by the NAME value for whatever variable you are looking for. Then you could set some macro variables equal to some of the different values in the data set for that variable and print those to the log. Is that something you are trying to accomplish?
12-11-2015 02:26 AM
12-11-2015 09:24 AM
So, using the attrn() function, there are many different "attr-names" you can use in the second argument of the function. You currently have nobs hardcoded to return which specifies the number of physical observations. You could add an additional parameter in your %macro statement to set whatever attr-name you want to use with the attrn() function. The statement would change to "%macro datatt(data=, attribute=, type=, notfound=, attrname=);". All the different types of attributes you can find at the following link: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212040.htm
I would modify the nobs in the second argument of the attrn() function and set it equal to "&attrname". Then in your call of the datatt macro, if you wanted to display nobs, you just call it like "%datatt(data=sashelp.class, attribute=age, type=n, notfound=, attrname=nobs);".
12-14-2015 11:22 PM
12-15-2015 09:54 AM
Change the "&&attrname" to "&attrname". Also, you need to include the notfound and attrname parameters in the %macro statement. Instead of "%macro datatt(data=,attribute=,type=);", try doing "%macro datatt(data=,attribute=,type=,notfound=,attrname=);". That should fix those errors.
12-16-2015 04:11 AM