Hi i'm trying to move the values in GROUP and PARAM in the same column as the values in criteria and put blank rows in between them. What is the most efficient way to do this?
data have;
infile datalines dsd dlm=",";
input group $ param $ criteria $ value $;
datalines;
colors, red, >3, 2
colors, blue, <3, 3
cars, ford, >55, 34
cars, chevy, >23, 45
;
run;
desired output:
edited (how it's supposed to really look like):
Why do you want to change your data set to this really unusual and difficult-to-work-with arrangement?
Is it for some sort of table?
Can you provide more of the actual problem, rather than then details of SAS coding?
If you are just trying to print a report just use a data step and the PUT statement.
data _null_;
set have;
put group / param / criteria / 'count' @20 value / ;
run;
colors red >3 count 2 colors blue <3 count 3 cars ford >55 count 34 cars chevy >23 count 45
The best thing i could come up (sort order matters in the end as it will be sorted BY GROUP PARAM CRITERIA). I say this because currently this doesn't match the desired output in the OP, but that's ok.
data want; set have; output; output; output; run;
proc sort; by group param criteria; run;
data want1; set want;
by group param criteria;
if first.param and first.criteria then count=0; count +1;
if count=1 then do;
criteria=group;
value="";
end;
if count=2 then do;
criteria=param;
value="";
end;
keep criteria value;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.