BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

Just wondering if anyone has a clue about what is wrong with a bit of my program. I am getting an error on the log -
SYMBOLGEN: Macro variable FIELDVALUE resolves to
SYMBOLGEN: Macro variable DSID resolves to 1
SYMBOLGEN: Macro variable VAR_LIST resolves to FUND_CODE FUND_ID LONG_NAME
SYMBOLGEN: Macro variable DSID resolves to 1
WARNING: Argument 2 to function GETVARC referenced by the %SYSFUNC or %QSYSFUNC macro function
is out of range.

What I'm trying to do is read and output content of a dataset to an external file.

%macro json;
%let dsid=%sysfunc(open(work.fundinfo));
%if &dsid ne 0 %then
%do;
%do %while(%sysfunc(fetch(&dsid)) = 0);
%let number_of_vars = %sysfunc(countw(&var_list));
put fund_code;
%let fieldvalue= %sysfunc(getvarc(&dsid, 1));
put "&fieldvalue";
%end;
%let rc=%sysfunc(close(&dsid));
%end; /* End do - if */
%mend;

The problem seems to be happening to the first of the three column of the dataset. If I change the getvarc to look for column 2, it works fine. Column 1 is a number type and columns 2 & 3 are text - it shouldnt make a difference.

Can anyone help? Thanks.
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Obviously it does make a difference with SAS handling CHARACTER and NUMERIC variables differently. Did a search at the SAS support website http://support.sas.com/ and this DOC gem reference comes up.

Do you really need to have a mixture of macro and DATA step for your application processing?


Scott Barry
SBBWorks, Inc.

SAS 9.2 LANGUAGE REFERENCE

http://support.sas.com/documentation/cdl/en/sclref/59578/HTML/default/a000144252.htm
deleted_user
Not applicable
I think so...

What i'm doing is reading a dataset using the open through the DDV and then trying to output to a text file using a dummy dataset (file out). The reason I need to output to a file is what I am trying to do is read in the contents of the dataset and output it in a special syntax.. kind of like xml. with the tags as the colum names and the content as the contents of the tags.
Olivier
Pyrite | Level 9
I think you would also achieve that using a simple Data step, with arrays, FILE and PUT statements, and VNAME (or VLABEL) function to retrieve the current variable name or label.
In fact, this is how I create XML files, if it is for one-shot use. If not, I'd rather create a custom markup ODS destination using the Template procedure.

Olivier
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Have a look at the SAS support website http://support.sas.com/ and search for ODS MARKUP TAGSET XML for your keywords. Or, as Olivier mentioned, a simple DATA step process to an external file would be more efficient.

Scott Barry
SBBWorks, Inc.

http://www2.sas.com/proceedings/sugi27/p134-27.pdf
Cynthia_sas
SAS Super FREQ
Hi:
That is pretty much a description of what the SAS XML Libname Engine does. For example:
[pre]
libname simple xml 'c:\temp\dataout.xml';

data simple.classout;
set sashelp.class;
run;
[/pre]

gives you data like this:
[pre]
<CLASSOUT>
<Name> Alfred </Name>
<Sex> M </Sex>
<Age> 14 </Age>
<Height> 69 </Height>
<Weight> 112.5 </Weight>
</CLASSOUT>
<CLASSOUT>
<Name> Alice </Name>
<Sex> F </Sex>
<Age> 13 </Age>
<Height> 56.5 </Height>
<Weight> 84 </Weight>
</CLASSOUT>
[/pre]

...complete with XML processing instruction and root tag at the top of the file. Otherwise, I agree with Scott and Olivier-- macro is probably overkill for this until you have the program working for ONE dataset -- then you can make it work for more than one by adding macro coding. But the bulk of the work can be done by either SXLE or ODS MARKUP. At this point, however, unless you want the default XML for an XML report, I'd recommend sticking with the Libname Engine.

cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1714 views
  • 0 likes
  • 4 in conversation