BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MaryA_Marion
Lapis Lazuli | Level 10

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
;

 

1 ACCEPTED SOLUTION

Accepted Solutions
MaryA_Marion
Lapis Lazuli | Level 10

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;

 

 

View solution in original post

3 REPLIES 3
sbxkoenk
SAS Super FREQ

Post moved by me to Graphics board (coming from Visual Analytics board).

Koen

sbxkoenk
SAS Super FREQ

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

MaryA_Marion
Lapis Lazuli | Level 10

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;

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1002 views
  • 0 likes
  • 2 in conversation