I'm trying to string together all values for a particular character variable that are observed within a BY group. For example, if i have the following data for the three observations within a BY group:
How would I create a character string variable with the value "aa-bb-cc" that would be reported as such for all three observations within the BY group?
Thanks so much,
Create a second file with the BY var list, using a DATA step, and define a RETAIN statement for the "concatenated string" variable. You will want to explore using the FIRST. and LAST. technique to assign or concatenate (either using || or !! for your concatenation operator), creating your new variable. Then use a DATA step MERGE process to combine your original file with the second file, placing your new variable back on the original file, as needed.
You can search the SAS support http://support.sas.com/ website using the Google advanced argument below to find related SAS-hosted documentation and other technical reference papers on the subject: