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

I'm in trouble to create the variable "score" in the table "gini&k.2", because what sas creates is:

 

gini score BA

0,2 . .

 

And what I need:

gini score

0,2 BA

 

Follows the code:

%macro ks_gini(perf, escores);

%do k=1 %to %sysfunc(countw(&escores));
%let escore0 = %scan(&escores, &k);

proc sort data = base_filtro (keep= &escore0. &perf.) out=sort_&escore0.;
by &escore0.;
run;

/*GINI*/

proc freq data=sort_&escore0. noprint;
tables &perf.*&escore0./ measures;
output out=gini&k. measures;
run;

data gini&k.2;
set gini&k. (keep= _SMDCR_ rename=(_SMDCR_=gini));
length score $20;
score = &escore0.;
FORMAT gini COMMAX20.3;
run;

proc append data=gini&k.2 base=gini;run;

%end;

%mend ks_gini;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Add the following:

options mprint symbolgen;

Run the macro code again, show the code run, the macro call and the log.

As posted, hard to tell what you're doing or where it could be going wrong.

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

Please post the complete log using "insert code" button to preserve formatting. Don't forget to activate mprint and symbolgen before executing the macro.

ballardw
Super User

Since you have given us no data, no definition for any of the macro variables, no example of the macro call with its parameters or a log entry showing what ran, I am afraid there is not much we can do with out more details.

 

I have a strong suspicion that for at least some of the values in you Escores macro variable that this line fails because of data type.

score = &escore0.;

If you &escore0. value does not include quotes then it will be treated as the name of a variable. Which almost certainly does not exist at the point this line executes because you have kept only one variable in the source set and renamed it to Gini. If your log shows notes about some oddly named variable you do not recognize as "Unitialized" that is almost certainly what happened.

 

I have a strong suspicion as well that if you showed an example of the starting data set and the desired result there is much easier way to accomplish this as it appears that you are basically transposing data.

 

Example data should be in form of a data step as well.

 

Reeza
Super User

Add the following:

options mprint symbolgen;

Run the macro code again, show the code run, the macro call and the log.

As posted, hard to tell what you're doing or where it could be going wrong.

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!

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.

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
  • 390 views
  • 0 likes
  • 4 in conversation