data supptrir (keep= qval qnam idvarval trseq);
set sdtm.supptrir;
where qnam='REVPER' and qval='Review 1';
trseq=input(idvarval,best.);
run;
above code should work (tested on another dataset), but for the current dataset it does not work. I got:
Idvarval length is 50. I tried both strip(idvarval) and compress(idvarval) in the input statement, also 8., ??best. etc but never worked. However, when I do it in two steps, it works:
data supptrir (keep=usubjid qval qnam idvarval);
set sdtm.supptrir;
where qnam='REVPER' and qval='Review 1';
run;
data supptrir;
set supptrir ;
trseq=input(idvarval,best.);
run;
what could be the reason? very strange.
Here's a possibility.
Perhaps TRSEQ is already part of SDTM.SUPPTRIR, and has a format connected with it such as 3.1. In that case, the format isn't wide enough to display the results you are getting. But the extra DATA step drops the existing TRSEQ (and its accompanying interfering format).
Enter in your 1st step the line:
put IDVARVAL $hex8. ;
And check - are the trailing characters after the ID number are realy spaces ('20'x in ascii ) ?
You can also do:
textID = translate(IDVARVAL, '#',' ');
put textID=
Do you see in log lines like: 10##### or still 10
Use the hex value in compress function.
Since PICTURES do not convey actual data VALUES show us your actual data. https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Here's a possibility.
Perhaps TRSEQ is already part of SDTM.SUPPTRIR, and has a format connected with it such as 3.1. In that case, the format isn't wide enough to display the results you are getting. But the extra DATA step drops the existing TRSEQ (and its accompanying interfering format).
Yes, this is the reason. There was already a TRSEQ variable, although it is all blank values. I should have checked that. Thanks for your hints.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.