03-24-2017 05:59 AM
I've just begin learning Enterprise Guide for a month.
I encountered the problem below.
In the picture, the data is continuous, but in the Program Name column, the yellow cells are useless. Therefore, I'd copy the first program name to the next cells in same column until next "PRO" in Column of "Cycle", and do the same action continually.
I'd count the Error code for each program, example...."Program X has 2 shift, 2 open and 1 limited".
Does it has any code or method to slove this?
The only way I think is "do loop", I even don't know it is correct or not. It's really difficult for me....
03-24-2017 07:35 AM
Here's some code that will do what you are asking for. However, the order of the columns will change:
if cycle='PRO' then New_Program_Name = Program_Name;
rename New_Program_Name = Program_Name;
If the order of the columns is important, you can preserve that. The way you would learn the most: find the length of Program_Name. Then insert between the DATA and SET statement:
length Date Time 8 Cycle $ 6 Program_Name New_Program_Name $ 6;
Those numbers are just examples ... you have to use whatever is in your data.
You can automate the process instead, but it will look a little complex. Insert between the DATA and SET statements:
if 5=4 then do;
set have (keep=date time cycle program_name);
New_Program_Name = program_name;
04-07-2017 04:57 AM
Thank you for your respond.
Sorry for late reply. I have discussed with my friend for two weeks. We still cannot solve this problem.
I follow your suggestion and put the code into the project.
We encountered the problem below. The column of "Program_Name" all disappeared.
Could you please help to see where the problem is?
I attached the excel file and the code below. Thank you very much again.
data want; if 5=4 then do; set WORK.'RAW DATA'n (keep=date time cycle program_name); New_Program_Name = program_name; end; set WORK.'RAW DATA'n; if cycle="PRO" then New_Program_Name = Program_Name; retain New_Program_Name; drop Program_Name; rename New_Program_Name = Program_Name; run;
04-07-2017 07:14 AM
Two things would help. What does the log look like when you run the program? And what does PROC CONTENTS show about the variables in the data set?
It's possible that a very simple fix is in order. Perhaps Program_name should be replaced by 'Program Name'n if that is the actual name of the variable in your data. Post the evidence one way or the other.