Hello,
This macro function should works but nothing append. What's wrong with that function?
%macro varexist(dsn=,varname=);
/*%local dsid vnum;*/
%let vnum=0;
%let dsid = %sysfunc(open(&dsn));
%if &dsid %then %do;
%let vnum = %sysfunc(varnum(&dsid,&varname));
%let dsid = %sysfunc(close(&dsid));
%put &=vnum;
%end;
%mend varexist;
%varexist(dsn=sashelp.class,varname=age);
I am not getting the variable position as it is suppose to
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Programme 8';
4 %LET _CLIENTPROCESSFLOWNAME='Flux de processus';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=SVG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 %macro HTML5AccessibleGraphSupported;
15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16 %mend;
17 FILENAME EGHTML TEMP;
18 ODS HTML5(ID=EGHTML) FILE=EGHTML
19 OPTIONS(BITMAP_MODE='INLINE')
20 %HTML5AccessibleGraphSupported
21 ENCODING='utf-8'
22 STYLE=HTMLBlue
23 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/8/Styles/HTMLBlue.css")
24 NOGTITLE
25 NOGFOOTNOTE
26 GPATH=&sasworklocation
27 ;
28
29 %macro varexist(dsn=,varname=);
30 %local dsid vnum;
31 %let vnum=0;
32 %let dsid = %sysfunc(open(&dsn));
33 %if &dsid %then %do;
34 %let vnum = %sysfunc(varnum(&dsid,&varname));
35 %let dsid = %sysfunc(close(&dsid));
36 %put &=vnum;
37 %end;
38 %mend varexist;
39 %varexist(dsn=sashelp.class,varname=age);
40
41
42 %LET _CLIENTTASKLABEL=;
43 %LET _CLIENTPROCESSFLOWNAME=;
44 %LET _CLIENTPROJECTPATH=;
45 %LET _CLIENTPROJECTPATHHOST=;
46 %LET _CLIENTPROJECTNAME=;
47 %LET _SASPROGRAMFILE=;
48 %LET _SASPROGRAMFILEHOST=;
49
50 ;*';*";*/;quit;run;
51 ODS _ALL_ CLOSE;
52
53
54 QUIT; RUN;
Your code works for me:
Set: options mprint mlogic symbolgen;
before running your macro to see details in the LOG about the execution.
The code worked for me even using the version from the LOG with the line numbers removed and get the same result as @SASKiwi .
the issue was solved by the SAS admin. That has nothing to do with the SAS code.
This inccident can be closed.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.