This might be asking to much, but the last step asks me to use a format width in the put statement for arguments without a format.
So I need to produce the following output with the macro:
data_null_ ;
set books.list;
file "list4.data";
put @1 bookid 4. author 5-34 @35 isbn isbn18. @43 yearpub comma6.;
run;
with the a macro call of : %writeoutD (books.list,list4.data,bookid author isbn yearpub,4. 30 isbn18. comma6.);
I tried changing it to the following:
%local newput i newpointer;
%do i=1 %to 4;
%if &i=1
%then %let newpointer=1;
%else %let newpointer=%eval(&newpointer+%sysfunc(scan(&formatlist,%eval(&i-1),%str( $),ap)));
%let newput=&newput @&newpointer %sysfunc(scan(&variables,&i,%str( ))) %sysfunc(scan(&formatlist,&i,%str( )));
%if %sysfunc(findc("scan(&formatlist,&i)",'.'))=0
%then %let newput=&newput %sysfunc(scan(&variables,&i,%str( ))) %eval(&newpointer)-%eval(&newpointer+%sysfunc(scan(&formatlist,&i,%str( $),ap))+1);
%end;
but it was a no-go, not sure if its in the wrong spot or something...any ideas?
This looks to be working. I created more macro variables, too hard to work with all those nested functions for me, I'm too old.
Message was edited by: data _null_
You're the best. A few questions:
1) %sysevalF(not not %index(&f,.)) < what is this going to return? I understand the index function finds the character position of the . in each format argument, but the double not is confusing me..
2) You use the structure "_&f" < what does this do?
3) Is the %sysevalF function just an alternative to %eval?
Thanks for everything, enjoy the holiday!
zkreflex wrote:
You're the best. A few questions:
1) %sysevalF(not not %index(&f,.)) < what is this going to return? I understand the index function finds the character position of the . in each format argument, but the double not is confusing me..
Not not just make it a Boolean I should have use the Boolean option. %let d=%sysevalF(%index(&f,.),boolean);
2) You use the structure "_&f" < what does this do?
We need to have something the FIND when the format has only numbers and dot. For example 10. would return 0 and we don't want that.
3) Is the %sysevalF function just an alternative to %eval?
Sort of but it does floating point arithmetic and has options like INTEGER and BOOLEAN.
Thanks for everything, enjoy the holiday!
Getting closer. "scan" should become "%scan" in two places, and the hard-coded @1 is not needed. It will be part of &NEWPUT.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: