SAS STUDIO Release: 3.8 (Enterprise Edition)
Is there a description of what form dataset should be in for sgplot and other s series plots? I have the following:
proc sgplot data=profile; series x=brand y=response / group=subject; run;
I want a very simple profile plot of lifetime * brand for each subject connecting lines between brands for each subject.
Is there a clue in this code as to what input form to use? I usually use longform. I am finding all sorts of graphs out there with code but coordinating the data set with the procedure is another matter.
DATA profile; INPUT brand $ response; subject=_n_; DATALINES; A 73 A 64 A 67 B 81 B 77 ;
Solution found. I was trying to enter subject numbers easily. They were not correct and all subsequent graphs were incorrect. I went back to the old technique of using scatter and series statements.
DATA profile;
INPUT subject brand $ response;
DATALINES;
1 A 73
2 A 64
3 A 67
1 B 81
2 B 77
;
proc sgplot data=profile;
scatter x=brand y=response / group=subject;
series x=brand y=response / group=subject;
run;
Post moved by me to Graphics board (coming from Visual Analytics board).
Koen
Hello,
With series statement in proc sgplot an a unique subject (subject only occurring once) you do not see anything as there's no marker by default and there's nothing to connect.
I think you want something like the below :
DATA profile;
INPUT brand $ response subject $;
*subject=_n_;
DATALINES;
A 73 1
A 64 2
A 67 3
B 81 1
B 77 2
;
run;
proc sgplot data=profile;
series x=brand y=response / group=subject;
scatter x=brand y=response / group=subject;
run;
/* end of program */
Koen
Solution found. I was trying to enter subject numbers easily. They were not correct and all subsequent graphs were incorrect. I went back to the old technique of using scatter and series statements.
DATA profile;
INPUT subject brand $ response;
DATALINES;
1 A 73
2 A 64
3 A 67
1 B 81
2 B 77
;
proc sgplot data=profile;
scatter x=brand y=response / group=subject;
series x=brand y=response / group=subject;
run;
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.