Skip to content

Commit

Permalink
fix: ensuring consistent column names across invocations in output da…
Browse files Browse the repository at this point in the history
…taset
  • Loading branch information
^ committed Apr 11, 2024
1 parent a244a0b commit 602758c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
17 changes: 16 additions & 1 deletion all.sas
Original file line number Diff line number Diff line change
Expand Up @@ -29553,7 +29553,7 @@ Usage:
Valid values are "password" or "authorization_code" (unquoted).
@param [out] outds= (work.mx_getgroups) This output dataset will contain the
list of groups. Format:
|NAME:$32.|DESCRIPTION:$256.|GROUPID:best.|
|GROUPNAME:$32.|GROUPDESC:$256.|GROUPURI:best.|
|---|---|---|
|`SomeGroup `|`A group `|`1`|
|`Another Group`|`this is a different group`|`2`|
Expand Down Expand Up @@ -29587,6 +29587,15 @@ Usage:
outds=&outds,
mdebug=&mdebug
)
data &outds;
length groupuri groupname $32 groupdesc $128 ;
set &outds;
keep groupuri groupname groupdesc;
groupuri=cats(groupid);
groupname=name;
groupdesc=description;
run;
proc sort; by groupname; run;
%end;
%else %if &platform=SAS9 or &platform=SASMETA %then %do;
%if &user=0 %then %let user=;
Expand All @@ -29596,6 +29605,7 @@ Usage:
,repo=&repo
,mDebug=&mdebug
)
proc sort data=&outds; by groupname; run;
%end;
%else %if &platform=SASVIYA %then %do;
%if &user=0 %then %do;
Expand All @@ -29611,6 +29621,11 @@ Usage:
,grant_type=&grant_type
)
%end;
proc sort
data=&outds(rename=(id=groupuri name=groupname description=groupdesc))
out=&outds (keep=groupuri groupname groupdesc);
by groupname;
run;
%end;

%mend mx_getgroups;/**
Expand Down
10 changes: 10 additions & 0 deletions tests/x-platform/mx_getgroups.test.sas
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@
desc=groups were found,
outds=work.test_results
)
%mp_assertcols(work.test1,
cols=groupuri groupname groupdesc,
test=ALL,
desc=check all columns exist
)

%mx_getgroups(outds=work.test2,user=%mf_getuser())

%mp_assert(
iftrue=(%mf_nobs(work.test2)>0),
desc=groups for current user were found,
outds=work.test_results
)
%mp_assertcols(work.test2,
cols=groupuri groupname groupdesc,
test=ALL,
desc=check all columns exist
)
17 changes: 16 additions & 1 deletion xplatform/mx_getgroups.sas
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Valid values are "password" or "authorization_code" (unquoted).
@param [out] outds= (work.mx_getgroups) This output dataset will contain the
list of groups. Format:
|NAME:$32.|DESCRIPTION:$256.|GROUPID:best.|
|GROUPNAME:$32.|GROUPDESC:$256.|GROUPURI:best.|
|---|---|---|
|`SomeGroup `|`A group `|`1`|
|`Another Group`|`this is a different group`|`2`|
Expand Down Expand Up @@ -54,6 +54,15 @@
outds=&outds,
mdebug=&mdebug
)
data &outds;
length groupuri groupname $32 groupdesc $128 ;
set &outds;
keep groupuri groupname groupdesc;
groupuri=cats(groupid);
groupname=name;
groupdesc=description;
run;
proc sort; by groupname; run;
%end;
%else %if &platform=SAS9 or &platform=SASMETA %then %do;
%if &user=0 %then %let user=;
Expand All @@ -63,6 +72,7 @@
,repo=&repo
,mDebug=&mdebug
)
proc sort data=&outds; by groupname; run;
%end;
%else %if &platform=SASVIYA %then %do;
%if &user=0 %then %do;
Expand All @@ -78,6 +88,11 @@
,grant_type=&grant_type
)
%end;
proc sort
data=&outds(rename=(id=groupuri name=groupname description=groupdesc))
out=&outds (keep=groupuri groupname groupdesc);
by groupname;
run;
%end;

%mend mx_getgroups;

0 comments on commit 602758c

Please sign in to comment.