You forget to put in the proc print results (please paste into a box like the {i} - "insert code" so that we can see monopitch font).
And please, instead of reporting "something is wrong", describe the problem (i.e. point out and unexpected result, and what you expected).
"Wrong" is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: 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.
You have 3,491 cases with getup_time=ERRO. I presume this is the unexpected result. If so, please print out the input data for a few of those cases.
Thank you but when I run a proc print; var, there is appropriate data in both variables, but an error in the new variable it created for participants.
The either the algorithm for generating the new variable, or the format used to display it, are wrong.
Make a sample of 2 or 3 offending records. Run the program - but DON'T apply the format. Remember, if you are using the user-defined format I proposed, it would not support negative values (i.e. if you subtract the later time from the earlier time). If your result var is negative, then you have to revisit either the format, or recalculte the var so it's never negative.
How about providing some data just for a couple records that have "problems" and ONLY include the time related elements and code to read and process them. We do not need to see demographics and pick on the "usual" times to reduce the amount of stuff to look at.
Without having your data I'm willing to bet that the "minute" component of your times have 00 and 30 about equally split with 15 and 45 around half the number or 00 and 30 and that 00, 15, 30 and 45 comprise somewhere around 70 percent of your data.
Check the value of your time variables.
proc format ;
picture miltime low-high = '%0H%0M' (datatype=time) ;
run;
data TEST;
retain A 1e3 B 1e99 C 1e99 ;
putlog A= miltime. B= miltime. C= miltime.;
run;
This outputs ERROR since the value is invalid but doesnt generate an error.
A=0016 B=ERROR C=ERROR
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.