Thanks for the update @Kurt_Bremser . I have been able to implement the profile creation but i have observed and issue with my code.
I am currently encountering an issue with our process for checking the existence of logins or display names within our metadata system. Our intended logic is to prevent any actions if either a login or display name already exists in the metadata. However, the implementation is not functioning as expected.
Specifically, we have profiles with logins such as toto234 and toto123, but we are unable to create a profile with the login toto. The system incorrectly identifies toto as an existing login, even though it does not exist in our metadata.
Below is an excerpt from the log of the run:
DEBUG: Row 1 - user_id_exists=1 user_name_exists=0
NOTE: Profile with login toto already exists. No action.
I am seeking guidance on how we can accurately perform this check to ensure that only truly existing logins or display names are flagged, thereby allowing the creation of new profiles when appropriate.
Any insights or suggestions you could provide would be greatly appreciated.
Thank you for your assistance.
Best regards
Akshay
Code:
%macro check_existing_user(user_id, user_name);
%global user_id_exists user_name_exists;
%let user_id_exists = 0;
%let user_name_exists = 0;
/* Check if User ID exists */
data _null_;
length loginUri userIdValue $256 rc i 8;
i = 1;
rc = metadata_getnobj("omsobj:Login?@UserID='&user_id'", i, loginUri);
do while (rc > 0);
rc = metadata_getattr(loginUri, "UserID", userIdValue);
if lowcase(userIdValue) = lowcase("&user_id") then do;
call symputx("user_id_exists", "1");
leave;
end;
i + 1;
rc = metadata_getnobj("omsobj:Login?@UserID='&user_id'", i, loginUri);
end;
run;
/* Check if User Name exists */
data _null_;
length personUri displayNameValue $256 rc j 8;
j = 1;
rc = metadata_getnobj("omsobj:Person?@DisplayName='&user_name'", j, personUri);
do while (rc > 0);
rc = metadata_getattr(personUri, "DisplayName", displayNameValue);
if lowcase(displayNameValue) = lowcase("&user_name") then do;
call symputx("user_name_exists", "1");
leave;
end;
j + 1;
rc = metadata_getnobj("omsobj:Person?@DisplayName='&user_name'", j, personUri);
end;
run;
%mend;
You appear to be capturing the return code from the function calls
rc = metadata_getattr(loginUri, "UserID", userIdValue);
, but you are not testing the return code to check if the function succeeded before checking the value of the data set variable.
if lowcase(userIdValue) = lowcase("&user_id") then do;
Perhaps the call is failing and this is the cause of the false hits?
I merged your identical questions; posting a question once is sufficient. Superusers can move a topic to a different community if this is necessary.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.