BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

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;

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3
SASKiwi
PROC Star

Your code works for me:

SASKiwi_0-1709847234309.png

 

ballardw
Super User

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 .

alepage
Barite | Level 11

the issue was solved by the SAS admin.  That has nothing to do with the SAS code.

This inccident can be closed.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 380 views
  • 0 likes
  • 3 in conversation